This is an illustrative example to showcase scripts writing and add more module to three.js editor.
You need to add OrbitControls Module, by default, OrbitControls Module is not included in the three.js editor.
- open https://threejs.org/editor/
- import example from the json file in ./examples/
- copy and save the scripts to the corresponding object and entities in the scene at the editor bottom right
init-add-audio
The script will add audio-related modules in the init-add-audio before running the scripts,
and play the marching music as the background sound.
It will stop play when hit stop in editor.
It uses THREE.Raycaster to check the mouse event with raycaster checking objects. Only play sound when click the helmet object. It will also play the corresponding sound based on the object rotation degree (updated).
init-add-center-origin-pivot
calculate the center of the object and add a pivot to the scence
update-rotate-y
rotate pivot and marble box under the head statue
update physicalWorld.stepSimulation
set minimal simulation delta