Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Engine } from "@babylonjs/core/Engines/engine";
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera";
import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight";
import { Mesh } from "@babylonjs/core/Meshes/mesh";
import { GridMaterial } from "@babylonjs/materials/grid/gridMaterial";
import "@babylonjs/core/Meshes/Builders/boxBuilder";
import "@babylonjs/core/Meshes/Builders/sphereBuilder";
const canvas = document.getElementById("renderCanvas") as HTMLCanvasElement;
const engine = new Engine(canvas);
var scene = new Scene(engine);
// This creates and positions a free camera (non-mesh)
var camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);
// This targets the camera to scene origin
camera.setTarget(Vector3.Zero());
// This attaches the camera to the canvas
camera.attachControl(canvas, true);
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);
// Default intensity is 1. Let's dim the light a small amount
light.intensity = 0.7;
import { Engine } from "@babylonjs/core/Engines/engine";
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera";
import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight";
import { Mesh } from "@babylonjs/core/Meshes/mesh";
import "@babylonjs/core/Materials/standardMaterial";
import "@babylonjs/core/Meshes/Builders/boxBuilder";
import "@babylonjs/core/Meshes/Builders/sphereBuilder";
const canvas = document.getElementById("renderCanvas") as HTMLCanvasElement;
const engine = new Engine(canvas);
var scene = new Scene(engine);
// This creates and positions a free camera (non-mesh)
var camera = new FreeCamera("camera1", new Vector3(0, 5, -10), scene);
// This targets the camera to scene origin
camera.setTarget(Vector3.Zero());
// This attaches the camera to the canvas
camera.attachControl(canvas, true);
// This creates a light, aiming 0,1,0 - to the sky (non-mesh)
var light = new HemisphericLight("light1", new Vector3(0, 1, 0), scene);
// Default intensity is 1. Let's dim the light a small amount
light.intensity = 0.7;
var initScene = function() {
// Creates the canvas
var renderedCanvas = document.createElement("canvas");
renderedCanvas.className = "vjs-tech";
videoEl.parentElement.insertBefore(renderedCanvas, videoEl);
videoEl.style.display = "none";
// Creates the default babylonjs scene
var engine = new Engine(renderedCanvas, true, {
disableWebGL2Support: settings.disableWebGL2Support
});
// Workaround http://localhost:8080/indexCode.html
engine.getCaps().vertexArrayObject = false;
var scene = new Scene(engine);
// Set the hardware scaling level
const scaling = Math.max(settings.hardwareScalingLevel, 1 / (window.devicePixelRatio || 4));
engine.setHardwareScalingLevel(scaling);
// Helps reducing the needed number of draw calls
scene.renderTargetsEnabled = false;
scene.clearColor = new Color4(0, 0, 0, 1);
scene.onPointerObservable.add(function() {
player.userActive(true);
});
// No need of clear or depth buffer as it is a 360 video only
scene.autoClear = false;
scene.autoClearDepthAndStencil = false;
engine.setDepthBuffer(false);
function initScene(self, canvas, opts) {
// init internal properties
self._engine = new Engine(canvas, opts.antiAlias, {
preserveDrawingBuffer: opts.preserveDrawingBuffer,
})
self._scene = new Scene(self._engine)
var scene = self._scene
// remove built-in listeners
scene.detachControl()
// octree setup
self._octree = new Octree($ => {})
self._octree.blocks = []
scene._selectionOctree = self._octree
// camera, and empty mesh to hold it, and one to accumulate rotations
self._cameraHolder = new Mesh('camHolder', scene)
self._camera = new FreeCamera('camera', new Vector3(0, 0, 0), scene)
self._camera.parent = self._cameraHolder
self._camera.minZ = .01
self._cameraHolder.visibility = false