forked from Orillusion/orillusion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hdrSky): Distinguish HDR/LDR texture (Orillusion#171)
Distinguish between HDR and LDR sky box rendering methods update import path. Reuse variables simplified code
- Loading branch information
Showing
17 changed files
with
182 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,22 @@ | ||
import { GUIHelp } from "@orillusion/debug/GUIHelp"; | ||
import { Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, Texture, SkyRenderer, BoxGeometry, LitMaterial, MeshRenderer, Object3D } from "@orillusion/core"; | ||
import { createExampleScene } from "@samples/utils/ExampleScene"; | ||
import { Engine3D, Scene3D, SkyRenderer, Object3DUtil } from "@orillusion/core"; | ||
|
||
// sample to replace standard sky map | ||
class Sample_BitmapCubeStdSky { | ||
private _scene: Scene3D; | ||
async run() { | ||
// init engine | ||
await Engine3D.init({}); | ||
|
||
// init scene | ||
this._scene = new Scene3D(); | ||
|
||
// init camera3D | ||
let mainCamera = CameraUtil.createCamera3D(null, this._scene); | ||
mainCamera.perspective(60, Engine3D.aspect, 1, 2000.0); | ||
|
||
// camera controller | ||
let hoverCameraController = mainCamera.object3D.addComponent(HoverCameraController); | ||
hoverCameraController.setCamera(45, -10, 10); | ||
let scene: Scene3D = createExampleScene().scene; | ||
let sky = scene.getOrAddComponent(SkyRenderer); | ||
sky.map = await Engine3D.res.loadTextureCubeStd('sky/StandardCubeMap-2.jpg'); | ||
|
||
// create a basic cube | ||
let cubeObj = new Object3D(); | ||
let mr = cubeObj.addComponent(MeshRenderer); | ||
mr.geometry = new BoxGeometry(); | ||
let mat = new LitMaterial(); | ||
mr.material = mat; | ||
this._scene.addChild(cubeObj); | ||
|
||
// init view3D | ||
let view = new View3D(); | ||
view.scene = this._scene; | ||
view.camera = mainCamera; | ||
scene.addChild(Object3DUtil.GetSingleCube(10, 10, 10, 0.6, 0.6, 0.6)); | ||
|
||
// start renderer | ||
Engine3D.startRenderView(view); | ||
|
||
// load standard sky texture | ||
let url = 'sky/StandardCubeMap-2.jpg'; | ||
|
||
let sky = this._scene.addComponent(SkyRenderer) | ||
sky.map = await Engine3D.res.loadTextureCubeStd(url); | ||
this._scene.envMap = sky.map | ||
Engine3D.startRenderView(scene.view); | ||
} | ||
|
||
} | ||
|
||
new Sample_BitmapCubeStdSky().run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,24 @@ | ||
import { GUIHelp } from "@orillusion/debug/GUIHelp"; | ||
import { Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, Texture, SkyRenderer, BoxGeometry, LitMaterial, MeshRenderer, Object3D } from "@orillusion/core"; | ||
import { createExampleScene } from "@samples/utils/ExampleScene"; | ||
import { Engine3D, Scene3D, SkyRenderer, Object3DUtil } from "@orillusion/core"; | ||
|
||
// sample to replace hdr sky map | ||
class Sample_HDRSky { | ||
private _scene: Scene3D; | ||
private _externalTexture: Texture; | ||
private _originTexture: Texture; | ||
private _useExternal: boolean = false; | ||
async run() { | ||
// init engine | ||
await Engine3D.init({}); | ||
|
||
// init scene | ||
this._scene = new Scene3D(); | ||
// load sky texture | ||
let sky = this._scene.addComponent(SkyRenderer) | ||
let scene: Scene3D = createExampleScene().scene; | ||
let sky = scene.getOrAddComponent(SkyRenderer); | ||
sky.map = await Engine3D.res.loadHDRTextureCube('/hdri/sunset.hdr'); | ||
this._scene.envMap = sky.map | ||
|
||
// init camera3D | ||
let mainCamera = CameraUtil.createCamera3D(null, this._scene); | ||
mainCamera.perspective(60, Engine3D.aspect, 1, 2000.0); | ||
|
||
// create a basic cube | ||
let cubeObj = new Object3D(); | ||
let mr = cubeObj.addComponent(MeshRenderer); | ||
mr.geometry = new BoxGeometry(); | ||
let mat = new LitMaterial(); | ||
mr.material = mat; | ||
this._scene.addChild(cubeObj); | ||
|
||
// camera controller | ||
let hoverCameraController = mainCamera.object3D.addComponent(HoverCameraController); | ||
hoverCameraController.setCamera(45, -10, 10); | ||
|
||
// init view3D | ||
let view = new View3D(); | ||
view.scene = this._scene; | ||
view.camera = mainCamera; | ||
scene.addChild(Object3DUtil.GetSingleCube(10, 10, 10, 0.6, 0.6, 0.6)); | ||
|
||
// start renderer | ||
Engine3D.startRenderView(view); | ||
Engine3D.startRenderView(scene.view); | ||
} | ||
|
||
} | ||
|
||
|
||
new Sample_HDRSky().run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.