Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async setupModels() {
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
}
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
}
async setupModels() {
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['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
}
init = async () => {
const lighting = new Lighting();
await lighting.setupAsync();
this.game.scene.add(lighting);
this.moverGroup = new THREE.Object3D();
this.game.scene.add(this.moverGroup);
//make floor
const floorGroup = new THREE.Object3D();
this.floorMaterial = new THREE.MeshLambertMaterial({
color: Colors.floor, //diffuse
emissive: Colors.dark,
side: THREE.DoubleSide,
});
this.floorMaterial.flatShading = true;
//add extra x width
this.floorGeometry = new THREE.PlaneGeometry(
Settings.FLOOR_WIDTH + 1200,
Settings.FLOOR_DEPTH,
FLOOR_RES,
FLOOR_RES,
);
const floorMesh = new THREE.Mesh(this.floorGeometry, [this.floorMaterial]);
floorGroup.add(floorMesh);
this.moverGroup.add(floorGroup);
floorMesh.rotation.x = Math.PI / 2;
floorGroup.position.y = FLOOR_YPOS;
this.moverGroup.position.z = -Settings.MOVE_STEP;
loadAsync = async scene => {
const geometry = new THREE.PlaneGeometry(1000, 1000, 1, 1);
const texture = await ExpoTHREE.loadAsync({
uri:
'http://fc06.deviantart.net/fs71/f/2012/185/9/2/tileable_futuristic_grid_by_ndugger-d55yz5h.png',
});
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(70, 70);
const material = new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide,
});
const mesh = new THREE.Mesh(geometry, material);
this.add(mesh);
await super.loadAsync(scene);
};
}
side: THREE.DoubleSide,
});
const materialDepthBasic = new THREE.MeshDepthMaterial({
depthPacking: THREE.BasicDepthPacking,
displacementMap: displacementMap,
displacementScale: SCALE,
displacementBias: BIAS,
side: THREE.DoubleSide,
});
const materialDepthRGBA = new THREE.MeshDepthMaterial({
depthPacking: THREE.RGBADepthPacking,
displacementMap: displacementMap,
displacementScale: SCALE,
displacementBias: BIAS,
side: THREE.DoubleSide,
});
const materialNormal = new THREE.MeshNormalMaterial({
displacementMap: displacementMap,
displacementScale: SCALE,
displacementBias: BIAS,
normalMap: normalMap,
normalScale: new THREE.Vector2(1, -1),
//flatShading: true,
side: THREE.DoubleSide,
});
const geometry = object.children[0].geometry;
geometry.attributes.uv2 = geometry.attributes.uv;
geometry.center();
const mesh = new THREE.Mesh(geometry, materialStandard);
mesh.scale.multiplyScalar(0.25);
const displacementMap = await ExpoTHREE.loadAsync(obj['displacement.jpg']);
const object = await ExpoTHREE.loadAsync(obj['ninjaHead_Low.obj']);
const materialStandard = new THREE.MeshStandardMaterial({
color: 0xffffff,
metalness: 0.5,
roughness: 0.6,
displacementMap: displacementMap,
displacementScale: SCALE,
displacementBias: BIAS,
aoMap: aoMap,
normalMap: normalMap,
normalScale: new THREE.Vector2(1, -1),
//flatShading: true,
side: THREE.DoubleSide,
});
const materialDepthBasic = new THREE.MeshDepthMaterial({
depthPacking: THREE.BasicDepthPacking,
displacementMap: displacementMap,
displacementScale: SCALE,
displacementBias: BIAS,
side: THREE.DoubleSide,
});
const materialDepthRGBA = new THREE.MeshDepthMaterial({
depthPacking: THREE.RGBADepthPacking,
displacementMap: displacementMap,
displacementScale: SCALE,
displacementBias: BIAS,
side: THREE.DoubleSide,
});
Game.prototype.addAABBMarker = function(aabb, color) {
var geometry = new THREE.CubeGeometry(
aabb.width(),
aabb.height(),
aabb.depth(),
);
var material = new THREE.MeshBasicMaterial({
color: color || 0xffffff,
wireframe: true,
transparent: true,
opacity: 0.5,
side: THREE.DoubleSide,
});
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(
aabb.x0() + aabb.width() / 2,
aabb.y0() + aabb.height() / 2,
aabb.z0() + aabb.depth() / 2,
);
this.scene.add(mesh);
return mesh;
};