Skip to content Skip to sidebar Skip to footer

Three.js - Drag Collada Files

My objects are moving on the XZ axis through drag and drop. Unfortunately the collada files doesn't act like them... Here is my code: var container; var camera, controls, scene, r

Solution 1:

Solution with eventcontrols ( example http://alexan0308.github.io/threejs/examples/controls_events_loaders.html )

<script src="js/controls/EventsControls.js"></script>

EventsControls2 = new EventsControls(camera, renderer.domElement);
EventsControls2.map = checkerboard;

EventsControls2.attachEvent('mouseOver', function() {

    this.container.style.cursor = 'pointer';

});

EventsControls2.attachEvent('mouseOut', function() {

    this.container.style.cursor = 'auto';

});

EventsControls2.attachEvent('dragAndDrop', function() {

    this.container.style.cursor = 'move';
    this.focused.position.y = this.previous.y;

});



var loader = new THREE.ColladaLoader();
var Scale = new THREE.Vector3(20, 20, 20);
EventsControls2.scale.copy(Scale);
EventsControls2.offsetUse = true;

loader.options.convertUpAxis = true;
loader.load('models/monster/monster.dae', function(collada) {
    var dae = collada.scene;
    dae.position.set(0, 0, 0);
    dae.scale.set(1 / Scale.x, 1 / Scale.y, 1 / Scale.z);

    dae.updateMatrix();

    scene.add(dae);
    EventsControls2.attach(dae);
});

Post a Comment for "Three.js - Drag Collada Files"