Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let _stereo = new THREE.StereoCamera();
_stereo.aspect = 0.5;
let _params = {
minFilter: THREE.LinearFilter,
magFilter: THREE.NearestFilter,
format: THREE.RGBAFormat,
};
let _renderTarget = new THREE.WebGLRenderTarget(512, 512, _params);
_renderTarget.scissorTest = true;
// Distortion Mesh ported from:
// https://github.com/borismus/webvr-boilerplate/blob/master/src/distortion/barrel-distortion-fragment.js
let distortion = new THREE.Vector2(0.441, 0.156);
let geometry = new THREE.PlaneBufferGeometry(2, 2, 10, 20)
.removeAttribute('normal')
.toNonIndexed();
let positions = geometry.attributes.position.array;
let uvs = geometry.attributes.uv.array;
// duplicate
let positions2 = new Float32Array(positions.length * 2);
positions2.set(positions);
positions2.set(positions, positions.length);
let uvs2 = new Float32Array(uvs.length * 2);
uvs2.set(uvs);
}
}
if (
(size.z === 0 && spans.x0 < spans.x1) ||
(size.x === 0 && spans.y0 > spans.y1)
) {
return [
new THREE.Vector2(height, 0),
new THREE.Vector2(0, 0),
new THREE.Vector2(0, width),
new THREE.Vector2(height, width),
];
} else {
return [
new THREE.Vector2(0, 0),
new THREE.Vector2(0, height),
new THREE.Vector2(width, height),
new THREE.Vector2(width, 0),
];
}
};
}
if (
(size.z === 0 && spans.x0 < spans.x1) ||
(size.x === 0 && spans.y0 > spans.y1)
) {
return [
new THREE.Vector2(height, 0),
new THREE.Vector2(0, 0),
new THREE.Vector2(0, width),
new THREE.Vector2(height, width),
];
} else {
return [
new THREE.Vector2(0, 0),
new THREE.Vector2(0, height),
new THREE.Vector2(width, height),
new THREE.Vector2(width, 0),
];
}
};
const normalMap = await ExpoTHREE.loadAsync(obj['normal.jpg']);
const aoMap = await ExpoTHREE.loadAsync(obj['ao.jpg']);
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,
);
const object = await ExpoTHREE.loadObjAsync({
asset: model['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 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);
ExpoTHREE.utils.scaleLongestSideToSize(mesh, 1);
ExpoTHREE.utils.alignMesh(mesh, { y: 1 });
this.scene.add(mesh);
this.mesh = mesh;
}
var height = size.x;
}
}
if (
(size.z === 0 && spans.x0 < spans.x1) ||
(size.x === 0 && spans.y0 > spans.y1)
) {
return [
new THREE.Vector2(height, 0),
new THREE.Vector2(0, 0),
new THREE.Vector2(0, width),
new THREE.Vector2(height, width),
];
} else {
return [
new THREE.Vector2(0, 0),
new THREE.Vector2(0, height),
new THREE.Vector2(width, height),
new THREE.Vector2(width, 0),
];
}
};
cloud.wrapS = THREE.RepeatWrapping;
cloud.wrapT = THREE.RepeatWrapping;
const lavatile = await ExpoTHREE.createTextureAsync({
asset: Assets.images.lava['lavatile.jpg'],
});
lavatile.wrapS = THREE.RepeatWrapping;
lavatile.wrapT = THREE.RepeatWrapping;
this.uniforms = {
fogDensity: { value: 0.45 },
fogColor: { value: new THREE.Vector3(0, 0, 0) },
time: { value: 1.0 },
resolution: { value: new THREE.Vector2() },
uvScale: { value: new THREE.Vector2(3.0, 1.0) },
texture1: { value: cloud },
texture2: { value: lavatile },
};
const size = 0.65;
const material = new THREE.ShaderMaterial({
uniforms: this.uniforms,
vertexShader: vertexShader,
fragmentShader: fragmentShader,
});
const mesh = new THREE.Mesh(
new THREE.TorusGeometry(size, 0.3, 30, 30),
material
);
mesh.rotation.x = 0.3;
if (spans.x0 > spans.x1) {
var width = size.x;
var height = size.y;
} else {
var width = size.y;
var height = size.x;
}
}
if (
(size.z === 0 && spans.x0 < spans.x1) ||
(size.x === 0 && spans.y0 > spans.y1)
) {
return [
new THREE.Vector2(height, 0),
new THREE.Vector2(0, 0),
new THREE.Vector2(0, width),
new THREE.Vector2(height, width),
];
} else {
return [
new THREE.Vector2(0, 0),
new THREE.Vector2(0, height),
new THREE.Vector2(width, height),
new THREE.Vector2(width, 0),
];
}
};
var width = size.x;
var height = size.y;
} else {
var width = size.y;
var height = size.x;
}
}
if (
(size.z === 0 && spans.x0 < spans.x1) ||
(size.x === 0 && spans.y0 > spans.y1)
) {
return [
new THREE.Vector2(height, 0),
new THREE.Vector2(0, 0),
new THREE.Vector2(0, width),
new THREE.Vector2(height, width),
];
} else {
return [
new THREE.Vector2(0, 0),
new THREE.Vector2(0, height),
new THREE.Vector2(width, height),
new THREE.Vector2(width, 0),
];
}
};
if (
(size.z === 0 && spans.x0 < spans.x1) ||
(size.x === 0 && spans.y0 > spans.y1)
) {
return [
new THREE.Vector2(height, 0),
new THREE.Vector2(0, 0),
new THREE.Vector2(0, width),
new THREE.Vector2(height, width),
];
} else {
return [
new THREE.Vector2(0, 0),
new THREE.Vector2(0, height),
new THREE.Vector2(width, height),
new THREE.Vector2(width, 0),
];
}
};