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(engine): Fixed a series of issues and improved functionality (Ori…
…llusion#255) 1. Supports MeshCollider; 2. Expand attribute animation to support more attribute curves and fix bugs in clone PropertyAnimation; 3. After picking up the UI from the GUI, it no longer penetrates into the 3D space to pick up 3D objects; 4. Support GUI for adaptive scaling based on screen size; 5. Fix a bug caused by UI Image switching to sprites belonging to different atlases in the GUI. 6. Fix bug: MeshRender clone; 7. Added API (getBaseColor) for material to obtain references to baseColor; 8. Improve the clone method of UnLitMaterial; 9. Fix errors of SphereColliderShape.ts 10. decoration errors of experimentalDecorators
- Loading branch information
Showing
36 changed files
with
744 additions
and
310 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { GUIHelp } from "@orillusion/debug/GUIHelp"; | ||
import { GUIUtil } from "@samples/utils/GUIUtil"; | ||
import { createExampleScene } from "@samples/utils/ExampleScene"; | ||
import { Scene3D, Engine3D, BoxGeometry, SphereGeometry, SphereColliderShape, BoxColliderShape, Vector3, Object3D, MeshRenderer, LitMaterial, ColliderComponent, PointerEvent3D, Color, MeshColliderShape } from "@orillusion/core"; | ||
|
||
class Sample_MeshColliderPick { | ||
scene: Scene3D; | ||
async run() { | ||
Engine3D.setting.pick.enable = true; | ||
Engine3D.setting.pick.mode = `bound`; | ||
|
||
// init Engine3D | ||
await Engine3D.init({}); | ||
|
||
let exampleScene = createExampleScene(); | ||
this.scene = exampleScene.scene; | ||
|
||
GUIHelp.init(); | ||
|
||
GUIUtil.renderDirLight(exampleScene.light, false); | ||
Engine3D.startRenderView(exampleScene.view); | ||
|
||
this.initPickObject(this.scene); | ||
} | ||
|
||
//create some interactive boxes | ||
private initPickObject(scene: Scene3D): void { | ||
let size: number = 9; | ||
|
||
//geometry | ||
let boxGeometry = new BoxGeometry(size, size, size); | ||
let sphereGeometry = new SphereGeometry(size / 2, 20, 20); | ||
|
||
//collider shape | ||
|
||
for (let i = 0; i < 10; i++) { | ||
let obj = new Object3D(); | ||
obj.name = 'sphere ' + i; | ||
scene.addChild(obj); | ||
obj.x = (i - 5) * 15; | ||
let renderer = obj.addComponent(MeshRenderer); | ||
renderer.geometry = i % 2 ? boxGeometry : sphereGeometry; | ||
renderer.material = new LitMaterial(); | ||
|
||
let meshShape = new MeshColliderShape(); | ||
meshShape.mesh = renderer.geometry; | ||
|
||
// register collider component | ||
let collider = obj.addComponent(ColliderComponent); | ||
collider.shape = meshShape; | ||
} | ||
let pickFire = Engine3D.views[0].pickFire; | ||
// register event | ||
pickFire.addEventListener(PointerEvent3D.PICK_CLICK, this.onMousePick, this); | ||
} | ||
|
||
private onMousePick(e: PointerEvent3D) { | ||
let pick = e.data.pick; | ||
if (pick && pick.object3D) { | ||
let obj = pick.object3D; | ||
let meshRenderer = obj.getComponent(MeshRenderer); | ||
//modify base color | ||
meshRenderer.material.baseColor = new Color(Math.random(), Math.random(), Math.random()) | ||
} | ||
} | ||
|
||
} | ||
|
||
new Sample_MeshColliderPick().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
Oops, something went wrong.