Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.init = function () {
THREE.Object3D.call(this);
this.handles = new THREE.Object3D();
this.pickers = new THREE.Object3D();
this.planes = new THREE.Object3D();
this.add(this.handles);
this.add(this.pickers);
this.add(this.planes);
// // PLANES
const planeGeometry = new THREE.PlaneBufferGeometry(50, 50, 2, 2);
const planeMaterial = new THREE.MeshBasicMaterial({ visible: false, side: THREE.DoubleSide });
const planes = {
XY: new THREE.Mesh(planeGeometry, planeMaterial),
YZ: new THREE.Mesh(planeGeometry, planeMaterial),
XZ: new THREE.Mesh(planeGeometry, planeMaterial),
XYZE: new THREE.Mesh(planeGeometry, planeMaterial),
};
this.activePlane = planes.XYZE;
planes.YZ.rotation.set(0, Math.PI / 2, 0);
planes.XZ.rotation.set(-Math.PI / 2, 0, 0);
for (const i in planes) {
planes[i].name = i;
this.planes.add(planes[i]);
_parseMaterial(section, url) {
const { textureCount } = this._getData(section);
if (textureCount > 1) {
throw new Error('Not supporting materials with more than one texture set');
}
const hasColors = Boolean(this._geometry.getAttribute('color'));
const material = new THREE.MeshBasicMaterial({
vertexColors: hasColors ? THREE.VertexColors : THREE.NoColors,
});
if (!textureCount) {
return material;
}
// The first child is data section
const textureChild = section.children[1];
// const { filterMode, addrModeU, addrModeV } = this._getData(textureChild);
const [ colorFile, alphaFile ] = textureChild.children.filter(child => (
child.type === 'RwString'
)).map(child => (
child.data
));
// const AddresModeMap = {
// RwDefault: THREE.ClampToEdgeWrapping,
// RwWrap: THREE.RepeatWrapping,
_parseMaterial(section) {
const { textureCount } = this._getData(section);
if (textureCount > 1) {
throw new Error('Not supporting materials with more than one texture set');
}
const material = new THREE.MeshBasicMaterial({
vertexColors: THREE.VertexColors,
});
if (!textureCount) {
return material;
}
// The first child is data section
const textureChild = section.children[1];
const [ colorFile, alphaFile ] = textureChild.children.filter(child => (
child.type === 'RwString'
)).map(child => (
child.data
));
const loader = new THREE.TextureLoader();
loader.setPath(this.path);
if (colorFile) {
this._resolveTexturePath(this._url, `${colorFile.toUpperCase()}.BMP`).then(texturePath => {
case 'UnknownTrigger0': {
const { target } = this.data;
const geometry = new THREE.SphereBufferGeometry(0.5, 4, 2);
const material = new THREE.MeshBasicMaterial({
color: zEntity.getMarkerColor(),
wireframe: true,
});
const sphere = new THREE.Mesh(geometry, material);
sphere.position.fromArray(target).sub(object3D.position);
this.el.setObject3D('mesh', sphere);
break;
}
case 'UnknownTrigger1': {
const { radius } = this.data;
const geometry = new THREE.SphereBufferGeometry(radius, 8, 8);
const material = new THREE.MeshBasicMaterial({
color: zEntity.getMarkerColor(),
wireframe: true,
});
const sphere = new THREE.Mesh(geometry, material);
this.el.setObject3D('mesh', sphere);
zEntity.toggleMarker(false);
break;
}
case 'UnknownTrigger2': {
// Nothing special here
break;
}
default:
warn('Unsupported trigger type: %s', type);
}
}