Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onContextCreateAsync = async (gl, arSession) => {
const {
innerWidth: width,
innerHeight: height,
devicePixelRatio: scale,
} = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl });
this.renderer.setPixelRatio(scale);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x000000, 1.0);
this.setupScene(arSession);
// resize listener
window.addEventListener('resize', this.onWindowResize, false);
// setup custom world
await this.setupWorldAsync();
this.props.onFinishedLoading();
};
_onContextCreate = async gl => {
const { innerWidth: width, innerHeight: height } = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl });
this.renderer.setPixelRatio(window.devicePixelRatio);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x000000, 1.0);
// scene
this.scene = new THREE.Scene();
this.scene.background = new THREE.Color(0xcccccc);
this.scene.fog = new THREE.FogExp2(0xcccccc, 0.002);
// camera
this.camera = new THREE.PerspectiveCamera(50, width / height, 1, 1000);
this.camera.position.z = 500;
this.camera.lookAt(new THREE.Vector3());
_onContextCreate = async gl => {
const {
innerWidth: width,
innerHeight: height,
devicePixelRatio: scale,
} = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl });
this.renderer.setPixelRatio(scale);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x339ce2);
// scene
this.scene = new THREE.Scene();
// camera
this.camera = new THREE.PerspectiveCamera(75, width / height, 1, 10000);
this.camera.position.z = 500;
this.camera.lookAt(new THREE.Vector3());
this.controls = new THREE.OrbitControls(this.camera);
this.controls.enableDamping = true;
// custom scene
_onContextCreate = async gl => {
const { innerWidth: width, innerHeight: height } = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl });
this.renderer.setPixelRatio(window.devicePixelRatio);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x000000, 1.0);
// scene
this.scene = new THREE.Scene();
this.scene.background = new THREE.Color(0xcccccc);
this.scene.fog = new THREE.FogExp2(0xcccccc, 0.002);
// camera
this.camera = new THREE.PerspectiveCamera(50, width / height, 1, 1000);
this.camera.position.z = 500;
this.camera.lookAt(new THREE.Vector3());
_onContextCreate = async (gl, arSession) => {
const {
innerWidth: width,
innerHeight: height,
devicePixelRatio: scale,
} = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl, antialias: false });
this.renderer.setPixelRatio(scale);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x000000, 1.0);
// scene
this.scene = new THREE.Scene();
if (AR) {
// AR Background Texture
this.scene.background = ExpoTHREE.createARBackgroundTexture(
arSession,
this.renderer
);
/// AR Camera
this.camera = ExpoTHREE.createARCamera(
_onContextCreate = async gl => {
const { innerWidth: width, innerHeight: height } = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl });
this.renderer.setPixelRatio(window.devicePixelRatio);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x000000, 1.0);
// scene
this.scene = new THREE.Scene();
this.scene.background = new THREE.Color(0xcccccc);
this.scene.fog = new THREE.FogExp2(0xcccccc, 0.002);
// camera
this.camera = new THREE.PerspectiveCamera(60, width / height, 1, 200000);
this.camera.position.set(0, 100, 2000);
this.camera.lookAt(new THREE.Vector3());
_onContextCreate = async (gl) => {
const { innerWidth: width, innerHeight: height, devicePixelRatio: scale } = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl });
this.renderer.setPixelRatio(scale);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x000000);
this.renderer.autoClear = false;
this._setupScene();
// resize listener
window.addEventListener('resize', this._onWindowResize, false);
this._onWindowResize();
}
var geometry = new THREE.PlaneBufferGeometry(1000, 1000);
geometry.rotateX(- Math.PI / 2);
this.plane = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ visible: false }));
this.scene.add(this.plane);
this.objects.push(this.plane);
// Lights
var ambientLight = new THREE.AmbientLight(0x606060);
this.scene.add(ambientLight);
var directionalLight = new THREE.DirectionalLight(0xffffff);
directionalLight.position.set(1, 0.75, 0.5).normalize();
this.scene.add(directionalLight);
// this.configureLights();
// NOTE: How to create an `Expo.GLView`-compatible THREE renderer
this.renderer = ExpoTHREE.createRenderer({ gl, antialias: true });
this.renderer.setSize(width, height);
this.renderer.setClearColor(0xf0f0f0);
this.setState({ camera })
let lastFrameTime;
const render = () => {
this._requestAnimationFrameID = requestAnimationFrame(render);
const now = 0.001 * global.nativePerformanceNow();
const dt = typeof lastFrameTime !== 'undefined'
? now - lastFrameTime
: 0.16666;
this.renderer.render(this.scene, camera);
onContextCreateAsync = async (gl, arSession) => {
const {
innerWidth: width,
innerHeight: height,
devicePixelRatio: scale,
} = window;
// renderer
this.renderer = ExpoTHREE.createRenderer({ gl });
this.renderer.setPixelRatio(scale);
this.renderer.setSize(width, height);
this.renderer.setClearColor(0x000000, 1.0);
this.setupScene(arSession);
// resize listener
window.addEventListener('resize', this.onWindowResize, false);
// setup custom world
await this.setupWorldAsync();
this.props.onFinishedLoading();
};
onContextCreate = async ({
gl,
canvas,
width,
height,
scale: pixelRatio,
}) => {
this.renderer = ExpoTHREE.createRenderer({
gl,
canvas,
width,
height,
pixelRatio,
});
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
this.camera.position.z = 5;
const geometry = new THREE.BoxGeometry(1, 1, 1);
const asset = Asset.fromModule(Assets.icons['ios.png']);
await asset.downloadAsync();
const map = await ExpoTHREE.createTextureAsync({ asset });
const material = new THREE.MeshBasicMaterial({