Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await super.setupModels();
const model = Assets.models.vtk['cube_no_compression.vtp'];
const geometry = await ExpoTHREE.loadAsync(model);
geometry.center();
geometry.computeVertexNormals();
const material = new THREE.MeshLambertMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
});
const mesh = new THREE.Mesh(geometry, material);
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh; // Save reference for rotation
}
child.material.side = THREE.FrontSide;
/// Apply other maps - maybe this is supposed to be automatic :[
child.material.normalMap = await ExpoTHREE.loadAsync(
model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_N.png']
);
child.material.specularMap = await ExpoTHREE.loadAsync(
model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_Body_S.png']
);
child.material.envMap = await ExpoTHREE.loadAsync(
model['B-AO_iOS_HERO_Bruce_Wayne_Batman_Arkham_Origins_DM_ENV.png']
);
}
});
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 5);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh; // Save reference for rotation
}
const model = Assets.models['3ds'].portalgun;
const mesh = await ExpoTHREE.loadAsync(
model['portalgun.3ds'],
null,
name => model.textures[name]
);
const normal = await ExpoTHREE.loadAsync(model.textures['normal.jpg']);
mesh.traverse(function(child) {
if (child instanceof THREE.Mesh) {
child.material.normalMap = normal;
}
});
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh; // Save reference for rotation
}
async setupModels() {
await super.setupModels();
const model = Assets.models.vtk['bunny.vtk'];
const geometry = await ExpoTHREE.loadAsync(model);
geometry.center();
geometry.computeVertexNormals();
const material = new THREE.MeshLambertMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
});
const mesh = new THREE.Mesh(geometry, material);
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh; // Save reference for rotation
}
const model = Assets.models.collada.stormtrooper;
const collada = await ExpoTHREE.loadDaeAsync({
asset: model['stormtrooper.dae'],
onAssetRequested: model,
});
const { scene: mesh, animations } = collada;
mesh.traverse(child => {
if (child instanceof THREE.Mesh) {
child.castShadow = true;
child.receiveShadow = true;
}
});
mesh.castShadow = true;
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 0.1);
this.mixer = new THREE.AnimationMixer(mesh);
this.mixer.clipAction(animations[0]).play();
const geometry = new THREE.PlaneBufferGeometry(1, 1, 32, 32);
const material = new THREE.ShadowMaterial();
material.opacity = 0.7;
const plane = new THREE.Mesh(geometry, material);
plane.receiveShadow = true;
plane.rotation.x = -Math.PI / 2;
let _mesh = new THREE.Object3D();
_mesh.add(mesh);
_mesh.add(plane);
this.mesh = _mesh; // Save reference for rotation
async setupModels() {
await super.setupModels();
const model = Assets.models['3mf']['cube_gears.3mf'];
const geometry = await ExpoTHREE.loadAsync(model);
geometry.center();
geometry.computeVertexNormals();
const material = new THREE.MeshLambertMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
});
const mesh = new THREE.Mesh(geometry, material);
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh; // Save reference for rotation
}
await super.setupModels();
const model = Assets.models.vtk['cube_ascii.vtp'];
const geometry = await ExpoTHREE.loadAsync(model);
geometry.center();
geometry.computeVertexNormals();
const material = new THREE.MeshLambertMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
});
const mesh = new THREE.Mesh(geometry, material);
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh; // Save reference for rotation
}
async setupModels() {
await super.setupModels();
const model = Assets.models.vtk['bunny.vtk'];
const geometry = await ExpoTHREE.loadAsync(model);
geometry.center();
geometry.computeVertexNormals();
const material = new THREE.MeshLambertMaterial({
color: 0xff0000,
side: THREE.DoubleSide,
});
const mesh = new THREE.Mesh(geometry, material);
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh; // Save reference for rotation
}
await super.setupModels();
const model = Assets.models.assimp.octaminator;
const object = await ExpoTHREE.loadAsync(
model['Octaminator.assimp'],
null,
model
);
if (!object) {
throw new Error('Failed to load model!');
}
const { object: mesh, animation } = object;
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 3);
this.scene.add(mesh);
this.animation = animation;
}