Hello
I’m new here.
I am struggling with 3d object rotating way which published three.js editor.
Tried search every way but increased confusing.
My process is simple.
import glb file in Three.js editor.
add lighting, material.
publish in html to view rotating with mouse.
that’s it all.
But can’t find to success this simple process. I tried import orbitcontrol.js and modify app.js etc…but never working.
Please point me what i miss and what should i do?
Thanks
Not 100% sure what you mean - is OrbitControls example what you’re looking for? (code’s in the bottom right, you have to create new OrbitControls(camera, renderer.domElement), like here, otherwise it won’t work)
Basically it’s same as your sample. but my process is from “three.js editor” made result. Did you made sample with three.js editor? searching for this, and someone told that Orbitcontrol is no available and use another way. follow is my html.
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<meta name="generator" content="Three.js Editor">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: sans-serif;
font-size: 11px;
background-color: #000;
margin: 0px;
}
canvas {
display: block;
}
</style>
</head>
<body ontouchstart="">
<script type="module">
import * as THREE from './js/three.module.js';
import { APP } from './js/app.js';
import { VRButton } from './js/VRButton.js';
window.THREE = THREE; // Used by APP Scripts.
window.VRButton = VRButton; // Used by APP Scripts.
var loader = new THREE.FileLoader();
loader.load( 'app.json', function ( text ) {
var player = new APP.Player();
player.load( JSON.parse( text ) );
player.setSize( window.innerWidth, window.innerHeight );
player.play();
document.body.appendChild( player.dom );
window.addEventListener( 'resize', function () {
player.setSize( window.innerWidth, window.innerHeight );
} );
} );
</script>
</body>
</html>
Tried orbitcontrol.js, app.js index.html modification way but no luck.
I just wonder anyone who use three.js editor workflow success orbit object.
please let me know what should i more clearly.
I dont understand what you mean with three.js “editor” workflow.
You need to import orbitcontrol the same way you import three (you need the orbitcontrol.js in the same place as three-module.js) and than you need to use it like @mjurczyk told you in the post above.
Add line 56 from this codepen for example. Feel free to copy-paste it 1:1, into app.js, in any place that already has camera and renderer defined. That’s kinda literally all you need.
(TBH, if you think publishing from editor will save you some time versus just writing the code, you’re wrong - they dont really maintain this workflow for many years - as is evident by the person above having no idea about it )
Thanks. your file works now. and appreciates advice. i think traditional way should be my workflow because looks get advice for another huddle. Thanks again!