Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.controls.addEventListener('objectChange', () => {
// Sync with components
const { object3D } = this.el;
this.el.setAttribute('position', object3D.position);
this.el.setAttribute('rotation', object3D.rotation.toArray()
.map(THREE.Math.radToDeg)
.join(' ')
);
});
sceneEl.object3D.add(this.controls);
handleComponentChanged(event) {
const { name, newData } = event.detail;
if (name === 'position') {
const { x, y, z } = newData;
this.el.setAttribute(this.attrName, 'position', [x, y, z]);
}
if (name === 'rotation') {
const { y } = newData;
const { rotation: oldRotation } = this.data;
this.el.setAttribute(this.attrName, 'rotation', [
Math.sin(THREE.Math.degToRad(y)), oldRotation[1],
Math.cos(THREE.Math.degToRad(y)),
]);
}
},
});
handleComponentChanged(event) {
const { name, newData } = event.detail;
if (name === 'position') {
const { x, y, z } = newData;
this.el.setAttribute(this.attrName, 'position', [x, y, z]);
}
if (name === 'rotation') {
const { y } = newData;
const { rotation: oldRotation } = this.data;
this.el.setAttribute(this.attrName, 'rotation', [
Math.sin(THREE.Math.degToRad(y)), oldRotation[1],
Math.cos(THREE.Math.degToRad(y)),
]);
}
},
});
handleComponentChanged(event) {
const { name, newData } = event.detail;
if (name === 'position') {
const { x, y, z } = newData;
this.el.setAttribute(this.attrName, 'position', [x, y, z]);
}
if (name === 'rotation') {
const { y } = newData;
const { rotation: oldRotation } = this.data;
this.el.setAttribute(this.attrName, 'rotation', [
Math.sin(THREE.Math.degToRad(y)), oldRotation[1],
Math.cos(THREE.Math.degToRad(y)),
]);
}
},
});
handleComponentChanged(event) {
const { name, newData } = event.detail;
if (name === 'position') {
const { x, y, z } = newData;
this.el.setAttribute(this.attrName, 'position', [x, y, z]);
}
if (name === 'rotation') {
const { y } = newData;
const { rotation: oldRotation } = this.data;
this.el.setAttribute(this.attrName, 'rotation', [
Math.sin(THREE.Math.degToRad(y)), oldRotation[1],
Math.cos(THREE.Math.degToRad(y)),
]);
}
},
});
handleComponentChanged(event) {
const { name, newData } = event.detail;
if (name === 'position') {
const { x, y, z } = newData;
this.el.setAttribute(this.attrName, 'position', [x, y, z]);
}
if (name === 'rotation') {
const { y } = newData;
const { rotation: oldRotation } = this.data;
this.el.setAttribute(this.attrName, 'rotation', [
Math.sin(THREE.Math.degToRad(y)), oldRotation[1],
Math.cos(THREE.Math.degToRad(y)),
]);
}
},
});
handleComponentChanged(event) {
const { name, newData } = event.detail;
if (name === 'position') {
const { x, y, z } = newData;
this.el.setAttribute(this.attrName, 'position', [x, y, z]);
}
if (name === 'rotation') {
const { y } = newData;
const { rotation: oldRotation } = this.data;
this.el.setAttribute(this.attrName, 'rotation', [
Math.sin(THREE.Math.degToRad(y)), oldRotation[1],
Math.cos(THREE.Math.degToRad(y)),
]);
}
},
});