diff --git a/package-lock.json b/package-lock.json index e7918bd..4b79b8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "devDependencies": { "@babylonjs/core": "^7.8.2", + "@babylonjs/materials": "^7.8.2", "ts-loader": "^9.5.1", "typescript": "^5.4.5", "webpack": "^5.91.0", @@ -23,6 +24,15 @@ "integrity": "sha512-IgZ28PqtkKIwwujShCTge5KceJliK1+UA3003TB3PejkTzbtmkXNaCXKbY5BWMU5V7trWo6J5NQ1PIVys8VPVQ==", "dev": true }, + "node_modules/@babylonjs/materials": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/@babylonjs/materials/-/materials-7.8.2.tgz", + "integrity": "sha512-GpiraAB2vya5iDzhHLeYSsOx+17aJwdw1Ql/SQ0xRTakS2b6az3GNjoio+aj8tX8ZZjuOG9NUd3hS/V+0NiAUw==", + "dev": true, + "peerDependencies": { + "@babylonjs/core": "^7.0.0" + } + }, "node_modules/@discoveryjs/json-ext": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", diff --git a/package.json b/package.json index d286abd..65796d7 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "homepage": "https://github.com/99-Knots/EditorDemo#readme", "devDependencies": { "@babylonjs/core": "^7.8.2", + "@babylonjs/materials": "^7.8.2", "ts-loader": "^9.5.1", "typescript": "^5.4.5", "webpack": "^5.91.0", diff --git a/src/index.ts b/src/index.ts index 142f62d..2addbfe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ -import * as BABYLON from '@babylonjs/core' +import * as BABYLON from '@babylonjs/core'; +import { SkyMaterial } from '@babylonjs/materials' const canvas = document.createElement('canvas'); canvas.id = "render-canvas"; @@ -9,9 +10,16 @@ document.body.appendChild(canvas); const engine = new BABYLON.Engine(canvas, true); const scene = new BABYLON.Scene(engine); -const camera = new BABYLON.ArcRotateCamera('camera1', 0, 0, 10, BABYLON.Vector3.Zero(), scene); +const camera = new BABYLON.ArcRotateCamera('camera1', 0.5, 0.9, 10, BABYLON.Vector3.Zero(), scene); camera.attachControl(canvas, true); +const skyMaterial = new SkyMaterial("skyMaterial", scene); +skyMaterial.backFaceCulling = false; +skyMaterial.inclination = 0.3; + +const skybox = BABYLON.MeshBuilder.CreateBox("skyBox", { size: 1000.0 }, scene); +skybox.material = skyMaterial; + const light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(1, 1, 0), scene); const cube = BABYLON.MeshBuilder.CreateBox('box', {}, scene);