lythreeframe 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +2646 -0
- package/dist/bundle.esm.js +2612 -0
- package/{src/index.ts → dist/index.d.ts} +40 -44
- package/dist/lythreeframe/AssetManagement/AssetDefines.d.ts +6 -0
- package/dist/lythreeframe/AssetManagement/AssetManager.d.ts +23 -0
- package/dist/lythreeframe/AssetManagement/AssetPointer/AssetPointer.d.ts +9 -0
- package/dist/lythreeframe/AssetManagement/Task/Task.d.ts +7 -0
- package/dist/lythreeframe/Container/SmartPointer.d.ts +10 -0
- package/dist/lythreeframe/Defines.d.ts +4 -0
- package/dist/lythreeframe/Delegate.d.ts +8 -0
- package/dist/lythreeframe/Factory/CameraFactory.d.ts +20 -0
- package/dist/lythreeframe/Factory/RendererFactory.d.ts +2 -0
- package/dist/lythreeframe/Frame/Controller.d.ts +40 -0
- package/dist/lythreeframe/Frame/Viewport.d.ts +50 -0
- package/dist/lythreeframe/Frame/World.d.ts +18 -0
- package/dist/lythreeframe/Geometry/PlaneGeometry.d.ts +3 -0
- package/dist/lythreeframe/Geometry/TriangleGeometry.d.ts +3 -0
- package/dist/lythreeframe/Library/ContainerLibrary.d.ts +3 -0
- package/dist/lythreeframe/Library/Math.d.ts +27 -0
- package/dist/lythreeframe/Library/ResourceLibrary.d.ts +6 -0
- package/dist/lythreeframe/Object/Actor.d.ts +86 -0
- package/dist/lythreeframe/Object/Actors/Camera/CameraActor.d.ts +4 -0
- package/dist/lythreeframe/Object/Actors/Light/DirectionalLightActor.d.ts +7 -0
- package/dist/lythreeframe/Object/Actors/Shape/BoxActor.d.ts +5 -0
- package/dist/lythreeframe/Object/Actors/Shape/PlaneActor.d.ts +9 -0
- package/dist/lythreeframe/Object/BaseObject.d.ts +10 -0
- package/dist/lythreeframe/Object/Components/2D/2DComponent.d.ts +13 -0
- package/dist/lythreeframe/Object/Components/Camera/CameraComponent.d.ts +26 -0
- package/dist/lythreeframe/Object/Components/Component.d.ts +17 -0
- package/dist/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.d.ts +15 -0
- package/dist/lythreeframe/Object/Components/Light/LightComponent.d.ts +12 -0
- package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.d.ts +7 -0
- package/dist/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.d.ts +13 -0
- package/dist/lythreeframe/Object/Components/Mesh/MeshComponent.d.ts +22 -0
- package/dist/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.d.ts +5 -0
- package/dist/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.d.ts +5 -0
- package/dist/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.d.ts +5 -0
- package/dist/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.d.ts +8 -0
- package/dist/lythreeframe/Object/Components/SceneComponent.d.ts +66 -0
- package/dist/lythreeframe/Object/PawnV2/FirstPerson.d.ts +5 -0
- package/dist/lythreeframe/Object/PawnV2/Oribital.d.ts +12 -0
- package/dist/lythreeframe/Object/PawnV2/Pawn.d.ts +14 -0
- package/dist/lythreeframe/Object/PawnV2/TransformControl.d.ts +46 -0
- package/dist/lythreeframe/PostProcess/Param/Bloom.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/DOF.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/Denoise.d.ts +7 -0
- package/dist/lythreeframe/PostProcess/Param/GTAO.d.ts +11 -0
- package/dist/lythreeframe/PostProcess/Param/LensFlare.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/MotionBlur.d.ts +4 -0
- package/dist/lythreeframe/PostProcess/Param/Outline.d.ts +17 -0
- package/dist/lythreeframe/PostProcess/Param/SSR.d.ts +6 -0
- package/dist/lythreeframe/PostProcess/Param/ToneMapping.d.ts +9 -0
- package/dist/lythreeframe/PostProcess/PostProcessParam.d.ts +16 -0
- package/dist/lythreeframe/PostProcess/WebGPUPostProcessFactory.d.ts +43 -0
- package/dist/lythreeframe/Shader/Postprocess/ColorShader.d.ts +29 -0
- package/dist/lythreeframe/ThreeJsApp.d.ts +35 -0
- package/package.json +26 -14
- package/dist/index.ts +0 -80
- package/rollup.config.js +0 -31
- package/src/draco/README.md +0 -32
- package/src/draco/draco_decoder.js +0 -34
- package/src/draco/draco_decoder.wasm +0 -0
- package/src/draco/draco_encoder.js +0 -33
- package/src/draco/draco_wasm_wrapper.js +0 -117
- package/src/draco/gltf/draco_decoder.js +0 -33
- package/src/draco/gltf/draco_decoder.wasm +0 -0
- package/src/draco/gltf/draco_encoder.js +0 -33
- package/src/draco/gltf/draco_wasm_wrapper.js +0 -116
- package/src/lythreeframe/AssetManagement/AssetDefines.ts +0 -8
- package/src/lythreeframe/AssetManagement/AssetManager.ts +0 -288
- package/src/lythreeframe/AssetManagement/AssetPointer/AssetPointer.ts +0 -41
- package/src/lythreeframe/AssetManagement/Task/Task.ts +0 -24
- package/src/lythreeframe/Container/SmartPointer.ts +0 -54
- package/src/lythreeframe/Defines.ts +0 -11
- package/src/lythreeframe/Delegate.ts +0 -37
- package/src/lythreeframe/Factory/CameraFactory.ts +0 -81
- package/src/lythreeframe/Factory/RendererFactory.ts +0 -7
- package/src/lythreeframe/Frame/Controller.ts +0 -261
- package/src/lythreeframe/Frame/Viewport.ts +0 -516
- package/src/lythreeframe/Frame/World.ts +0 -59
- package/src/lythreeframe/Frame.ts +0 -511
- package/src/lythreeframe/Geometry/PlaneGeometry.ts +0 -53
- package/src/lythreeframe/Geometry/TriangleGeometry.ts +0 -50
- package/src/lythreeframe/Library/ContainerLibrary.ts +0 -21
- package/src/lythreeframe/Library/MaterialLibrary.ts +0 -292
- package/src/lythreeframe/Library/Math.ts +0 -154
- package/src/lythreeframe/Library/ResourceLibrary.ts +0 -21
- package/src/lythreeframe/Object/Actor.ts +0 -571
- package/src/lythreeframe/Object/Actors/Camera/CameraActor.ts +0 -11
- package/src/lythreeframe/Object/Actors/Light/DirectionalLightActor.ts +0 -18
- package/src/lythreeframe/Object/Actors/Shape/BoxActor.ts +0 -20
- package/src/lythreeframe/Object/Actors/Shape/CurveActor.ts +0 -11
- package/src/lythreeframe/Object/Actors/Shape/PlaneActor.ts +0 -27
- package/src/lythreeframe/Object/Actors/Shape/TubeActor.ts +0 -37
- package/src/lythreeframe/Object/BaseObject.ts +0 -45
- package/src/lythreeframe/Object/Components/2D/2DComponent.ts +0 -64
- package/src/lythreeframe/Object/Components/Camera/CameraComponent.ts +0 -113
- package/src/lythreeframe/Object/Components/Component.ts +0 -67
- package/src/lythreeframe/Object/Components/Light/DirectionalLight/DirectionalLightComponent.ts +0 -78
- package/src/lythreeframe/Object/Components/Light/LightComponent.ts +0 -54
- package/src/lythreeframe/Object/Components/Mesh/InstanceMesh/InstanceMeshComponent.ts +0 -39
- package/src/lythreeframe/Object/Components/Mesh/InstanceMesh/MultiInstanceMeshComponent.ts +0 -115
- package/src/lythreeframe/Object/Components/Mesh/Line/CurveComponent.ts +0 -221
- package/src/lythreeframe/Object/Components/Mesh/MeshComponent.ts +0 -162
- package/src/lythreeframe/Object/Components/Mesh/Shape/BoxComponent.ts +0 -17
- package/src/lythreeframe/Object/Components/Mesh/Shape/PlaneComponent.ts +0 -10
- package/src/lythreeframe/Object/Components/Mesh/Shape/SphereComponent.ts +0 -10
- package/src/lythreeframe/Object/Components/Mesh/Sprite/SpriteComponent.ts +0 -32
- package/src/lythreeframe/Object/Components/SceneComponent.ts +0 -811
- package/src/lythreeframe/Object/Controller/Controller.ts +0 -764
- package/src/lythreeframe/Object/Pawn/CameraStatus.ts +0 -262
- package/src/lythreeframe/Object/Pawn/FirstPerson.ts +0 -230
- package/src/lythreeframe/Object/Pawn/Oribital.ts +0 -276
- package/src/lythreeframe/Object/Pawn/PawnBase.ts +0 -189
- package/src/lythreeframe/Object/Pawn/TopView.ts +0 -205
- package/src/lythreeframe/Object/Pawn/TransformControl.ts +0 -215
- package/src/lythreeframe/Object/Pawn/staticCamera.ts +0 -80
- package/src/lythreeframe/Object/PawnV2/FirstPerson.ts +0 -12
- package/src/lythreeframe/Object/PawnV2/Oribital.ts +0 -45
- package/src/lythreeframe/Object/PawnV2/Pawn.ts +0 -50
- package/src/lythreeframe/Object/PawnV2/TransformControl.ts +0 -202
- package/src/lythreeframe/PostProcess/Param/Bloom.ts +0 -12
- package/src/lythreeframe/PostProcess/Param/DOF.ts +0 -13
- package/src/lythreeframe/PostProcess/Param/Denoise.ts +0 -14
- package/src/lythreeframe/PostProcess/Param/GTAO.ts +0 -21
- package/src/lythreeframe/PostProcess/Param/LensFlare.ts +0 -11
- package/src/lythreeframe/PostProcess/Param/MotionBlur.ts +0 -8
- package/src/lythreeframe/PostProcess/Param/Outline.ts +0 -20
- package/src/lythreeframe/PostProcess/Param/SSR.ts +0 -11
- package/src/lythreeframe/PostProcess/Param/ToneMapping.ts +0 -31
- package/src/lythreeframe/PostProcess/PostProcessParam.ts +0 -26
- package/src/lythreeframe/PostProcess/WebGPUPostProcessFactory.ts +0 -217
- package/src/lythreeframe/Shader/Postprocess/ColorShader.ts +0 -49
- package/src/lythreeframe/ThreeJsApp.ts +0 -124
- package/tsconfig.json +0 -105
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class Delegate<T extends any[]>
|
|
2
|
-
{
|
|
3
|
-
private functions:Array<(...args:T) => void>;
|
|
4
|
-
|
|
5
|
-
constructor()
|
|
6
|
-
{
|
|
7
|
-
this.functions = [];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
broadcast(...args:T):void
|
|
11
|
-
{
|
|
12
|
-
this.functions.forEach((func) => func(...args));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
add(func:(...args:T) => void):void
|
|
16
|
-
{
|
|
17
|
-
this.functions.push(func);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
remove(func:(...args:T) => void):void
|
|
21
|
-
{
|
|
22
|
-
const index = this.functions.indexOf(func);
|
|
23
|
-
if (index >= 0)
|
|
24
|
-
{
|
|
25
|
-
this.functions.splice(index, 1);
|
|
26
|
-
}
|
|
27
|
-
else
|
|
28
|
-
{
|
|
29
|
-
console.warn("function not found");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
clear():void
|
|
34
|
-
{
|
|
35
|
-
this.functions = [];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {OrthographicCamera, PerspectiveCamera} from "three";
|
|
2
|
-
|
|
3
|
-
export interface CameraParam
|
|
4
|
-
{
|
|
5
|
-
near:number,
|
|
6
|
-
far:number,
|
|
7
|
-
param:PerspectiveCameraParam | OrthographicCameraParam
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface PerspectiveCameraParam
|
|
11
|
-
{
|
|
12
|
-
fov:number,
|
|
13
|
-
aspect:number,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface OrthographicCameraParam
|
|
17
|
-
{
|
|
18
|
-
left:number,
|
|
19
|
-
right:number,
|
|
20
|
-
top:number,
|
|
21
|
-
bottom:number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class CameraFactory
|
|
25
|
-
{
|
|
26
|
-
static createCamera(param:CameraParam)
|
|
27
|
-
{
|
|
28
|
-
let cam:PerspectiveCamera | OrthographicCamera | null = null;
|
|
29
|
-
if ("fov" in param.param && "aspect" in param.param)
|
|
30
|
-
{
|
|
31
|
-
cam = new PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
32
|
-
}
|
|
33
|
-
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param)
|
|
34
|
-
{
|
|
35
|
-
cam = new OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
36
|
-
}
|
|
37
|
-
if (!cam)
|
|
38
|
-
{
|
|
39
|
-
console.error("create camera failed");
|
|
40
|
-
debugger
|
|
41
|
-
throw Error("create camera failed");
|
|
42
|
-
}
|
|
43
|
-
return cam
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static updataCamera(param:CameraParam, camera:PerspectiveCamera | OrthographicCamera)
|
|
47
|
-
{
|
|
48
|
-
if ("fov" in param.param && "aspect" in param.param)
|
|
49
|
-
{
|
|
50
|
-
if (camera instanceof PerspectiveCamera)
|
|
51
|
-
{
|
|
52
|
-
camera.near = param.near;
|
|
53
|
-
camera.far = param.far;
|
|
54
|
-
camera.fov = param.param.fov;
|
|
55
|
-
camera.aspect = param.param.aspect;
|
|
56
|
-
return camera
|
|
57
|
-
}
|
|
58
|
-
else
|
|
59
|
-
{
|
|
60
|
-
return new PerspectiveCamera(param.param.fov, param.param.aspect, param.near, param.far);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if ("left" in param.param && "right" in param.param && "top" in param.param && "bottom" in param.param)
|
|
64
|
-
{
|
|
65
|
-
if (camera instanceof OrthographicCamera)
|
|
66
|
-
{
|
|
67
|
-
camera.near = param.near;
|
|
68
|
-
camera.far = param.far;
|
|
69
|
-
camera.left = param.param.left;
|
|
70
|
-
camera.right = param.param.right;
|
|
71
|
-
camera.top = param.param.top;
|
|
72
|
-
camera.bottom = param.param.bottom;
|
|
73
|
-
return camera
|
|
74
|
-
}
|
|
75
|
-
else
|
|
76
|
-
{
|
|
77
|
-
return new OrthographicCamera(param.param.left, param.param.right, param.param.top, param.param.bottom, param.near, param.far);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { ThreeJsApp } from "../ThreeJsApp";
|
|
2
|
-
import { Intersection, OrthographicCamera, PerspectiveCamera, Raycaster, Vector2 } from "three";
|
|
3
|
-
import { World } from "./World";
|
|
4
|
-
import { Viewport } from "./Viewport";
|
|
5
|
-
import { Pawn } from "../Object/PawnV2/Pawn";
|
|
6
|
-
import { Orbital } from "../Object/PawnV2/Oribital";
|
|
7
|
-
import { SceneComponent } from "../Object/Components/SceneComponent";
|
|
8
|
-
import { Delegate } from "../Delegate";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export class Controller
|
|
12
|
-
{
|
|
13
|
-
private prepareClickComponent: SceneComponent|null = null;
|
|
14
|
-
get camera(): PerspectiveCamera | OrthographicCamera
|
|
15
|
-
{
|
|
16
|
-
return this.app.camera;
|
|
17
|
-
}
|
|
18
|
-
get world(): World
|
|
19
|
-
{
|
|
20
|
-
return this.app.world
|
|
21
|
-
}
|
|
22
|
-
get viewPort(): Viewport
|
|
23
|
-
{
|
|
24
|
-
return this.app.viewport
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get pawn(): Pawn
|
|
28
|
-
{
|
|
29
|
-
if (!this._pawn)
|
|
30
|
-
{
|
|
31
|
-
throw Error("pawn is null")
|
|
32
|
-
}
|
|
33
|
-
return this._pawn
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private app : ThreeJsApp
|
|
37
|
-
private _pawn : Pawn | null = null
|
|
38
|
-
private raycaster: Raycaster;
|
|
39
|
-
|
|
40
|
-
private onPointerMove: ((event: MouseEvent) => void) = (event: MouseEvent) => { this.onPointerMoveEvent(event) }
|
|
41
|
-
private onPointerEnter: ((event: MouseEvent) => void) = (event: MouseEvent) => { this.onPointerEnterEvent(event) }
|
|
42
|
-
private onPointerLeave: ((event: MouseEvent) => void) = (event: MouseEvent) => { this.onPointerLeaveEvent(event) }
|
|
43
|
-
private onPointerUp: ((event: MouseEvent) => void) = (event: MouseEvent) => { this.onPointerUpEvent(event) }
|
|
44
|
-
private onPointerDown: ((event: MouseEvent) => void) = (event: MouseEvent) => { this.onPointerDownEvent(event) }
|
|
45
|
-
|
|
46
|
-
private pointerPosition: Vector2 = new Vector2()
|
|
47
|
-
|
|
48
|
-
private readonly doubleClickDelay: number = 250; // 双击判定时间间隔(毫秒)
|
|
49
|
-
private leftClickTimer: number | null = null;
|
|
50
|
-
private pointerLeftDownPosition: Vector2 = new Vector2();
|
|
51
|
-
|
|
52
|
-
private hoveringComponent: SceneComponent | null = null;
|
|
53
|
-
private _pointButtonIsDown:Set<number> = new Set()
|
|
54
|
-
get onClickNothingDelegate(): Delegate<[void]>
|
|
55
|
-
{
|
|
56
|
-
return this._onClickNothingDelegate
|
|
57
|
-
}
|
|
58
|
-
private _onClickNothingDelegate: Delegate<[void]> = new Delegate()
|
|
59
|
-
constructor(app: ThreeJsApp)
|
|
60
|
-
{
|
|
61
|
-
this.app = app
|
|
62
|
-
this._pawn = new Orbital(this)
|
|
63
|
-
this.pawn.possess()
|
|
64
|
-
this.raycaster = new Raycaster()
|
|
65
|
-
if (!this.viewPort.canvas)
|
|
66
|
-
{
|
|
67
|
-
throw Error("canvas is null")
|
|
68
|
-
}
|
|
69
|
-
this.viewPort.canvas.addEventListener("pointermove", this.onPointerMove)
|
|
70
|
-
this.viewPort.canvas.addEventListener("pointerenter", this.onPointerEnter)
|
|
71
|
-
this.viewPort.canvas.addEventListener("pointerleave", this.onPointerLeave)
|
|
72
|
-
this.viewPort.canvas.addEventListener("pointerup", this.onPointerUp)
|
|
73
|
-
this.viewPort.canvas.addEventListener("pointerdown", this.onPointerDown)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
init()
|
|
77
|
-
{
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
tick(deltaTime: number)
|
|
82
|
-
{
|
|
83
|
-
this.pawn.tick(deltaTime);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
destroy()
|
|
87
|
-
{
|
|
88
|
-
if (this.leftClickTimer)
|
|
89
|
-
{
|
|
90
|
-
clearTimeout(this.leftClickTimer);
|
|
91
|
-
this.leftClickTimer = null;
|
|
92
|
-
}
|
|
93
|
-
if (this.viewPort.canvas)
|
|
94
|
-
{
|
|
95
|
-
this.viewPort.canvas.removeEventListener("pointermove", this.onPointerMove);
|
|
96
|
-
this.viewPort.canvas.removeEventListener("pointerenter", this.onPointerEnter);
|
|
97
|
-
this.viewPort.canvas.removeEventListener("pointerleave", this.onPointerLeave);
|
|
98
|
-
this.viewPort.canvas.removeEventListener("pointerup", this.onPointerUp)
|
|
99
|
-
this.viewPort.canvas.removeEventListener("pointerdown", this.onPointerDown)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
this.pawn.unpossess()
|
|
103
|
-
this.pawn.destroy()
|
|
104
|
-
this._pawn = null
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
onPointerMoveEvent(event: MouseEvent)
|
|
108
|
-
{
|
|
109
|
-
if (!this.viewPort.canvas)
|
|
110
|
-
{
|
|
111
|
-
throw Error("canvas is null")
|
|
112
|
-
}
|
|
113
|
-
const canvasRect = this.viewPort.canvas.getBoundingClientRect();
|
|
114
|
-
const offsetX = canvasRect.left;
|
|
115
|
-
const offsetY = canvasRect.top;
|
|
116
|
-
const pointer = new Vector2(((event.clientX - offsetX) / this.viewPort.canvas.clientWidth) * 2 - 1, 1 - ((event.clientY - offsetY) / this.viewPort.canvas.clientHeight) * 2)
|
|
117
|
-
|
|
118
|
-
this.pointerPosition = pointer
|
|
119
|
-
|
|
120
|
-
if (this._pointButtonIsDown.size > 0)
|
|
121
|
-
{
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const hits = this.getHitResultUnderCursor()
|
|
126
|
-
|
|
127
|
-
if (hits)
|
|
128
|
-
{
|
|
129
|
-
let component = hits.object.userData["LYObject"]
|
|
130
|
-
if (component != this.hoveringComponent)
|
|
131
|
-
{
|
|
132
|
-
this.hoveringComponent?.onHorveringEnd();
|
|
133
|
-
this.hoveringComponent = null;
|
|
134
|
-
if (component instanceof SceneComponent && component.isHoverEnabled)
|
|
135
|
-
{
|
|
136
|
-
component.onHorveringBegin();
|
|
137
|
-
this.hoveringComponent = component;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else
|
|
142
|
-
{
|
|
143
|
-
this.hoveringComponent?.onHorveringEnd();
|
|
144
|
-
this.hoveringComponent = null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
onPointerUpEvent(event: MouseEvent)
|
|
149
|
-
{
|
|
150
|
-
this._pointButtonIsDown.delete(event.button)
|
|
151
|
-
|
|
152
|
-
if(event.button === 0)
|
|
153
|
-
{
|
|
154
|
-
const pointerOffset = new Vector2().subVectors(this.pointerLeftDownPosition, this.pointerPosition).length()
|
|
155
|
-
if (pointerOffset > 0.005)
|
|
156
|
-
{
|
|
157
|
-
if (this.leftClickTimer)
|
|
158
|
-
{
|
|
159
|
-
window.clearTimeout(this.leftClickTimer);
|
|
160
|
-
this.leftClickTimer = null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if(!this.leftClickTimer)
|
|
166
|
-
{
|
|
167
|
-
const hit = this.getHitResultUnderCursor();
|
|
168
|
-
let component = hit?hit.object.userData["LYObject"]:null;
|
|
169
|
-
if(component && component instanceof SceneComponent && component.isClickEnabled)
|
|
170
|
-
{
|
|
171
|
-
this.prepareClickComponent = component
|
|
172
|
-
this.leftClickTimer = window.setTimeout(()=>{
|
|
173
|
-
this.leftClickTimer = null;
|
|
174
|
-
|
|
175
|
-
if(this.prepareClickComponent)
|
|
176
|
-
{
|
|
177
|
-
this.prepareClickComponent.onClicked();
|
|
178
|
-
this.prepareClickComponent = null;
|
|
179
|
-
}
|
|
180
|
-
}, this.doubleClickDelay)
|
|
181
|
-
}
|
|
182
|
-
else
|
|
183
|
-
{
|
|
184
|
-
this._onClickNothingDelegate.broadcast()
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else
|
|
188
|
-
{
|
|
189
|
-
console.log("up 2, ", this.prepareClickComponent)
|
|
190
|
-
|
|
191
|
-
window. clearTimeout(this.leftClickTimer);
|
|
192
|
-
this.leftClickTimer = null;
|
|
193
|
-
if (this.prepareClickComponent)
|
|
194
|
-
{
|
|
195
|
-
this.prepareClickComponent.onDoubleClicked();
|
|
196
|
-
}
|
|
197
|
-
else
|
|
198
|
-
{
|
|
199
|
-
this._onClickNothingDelegate.broadcast()
|
|
200
|
-
}
|
|
201
|
-
this.prepareClickComponent = null;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
onPointerDownEvent(event: MouseEvent)
|
|
209
|
-
{
|
|
210
|
-
this._pointButtonIsDown.add(event.button)
|
|
211
|
-
if(event.button === 0)
|
|
212
|
-
{
|
|
213
|
-
this.pointerLeftDownPosition = this.pointerPosition.clone();
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
onPointerEnterEvent(event: MouseEvent)
|
|
221
|
-
{
|
|
222
|
-
if (!this.viewPort.canvas)
|
|
223
|
-
{
|
|
224
|
-
throw Error("canvas is null")
|
|
225
|
-
}
|
|
226
|
-
this.viewPort.canvas.addEventListener("pointermove", this.onPointerMove)
|
|
227
|
-
this.viewPort.canvas.addEventListener("pointerup", this.onPointerUp)
|
|
228
|
-
this.viewPort.canvas.addEventListener("pointerdown", this.onPointerDown)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
onPointerLeaveEvent(event: MouseEvent)
|
|
232
|
-
{
|
|
233
|
-
if (!this.viewPort.canvas)
|
|
234
|
-
{
|
|
235
|
-
throw Error("canvas is null")
|
|
236
|
-
}
|
|
237
|
-
this.viewPort.canvas.removeEventListener("pointermove", this.onPointerMove)
|
|
238
|
-
this.viewPort.canvas.removeEventListener("pointerup", this.onPointerUp)
|
|
239
|
-
this.viewPort.canvas.removeEventListener("pointerdown", this.onPointerDown)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
getHitResultUnderCursor(): Intersection | null
|
|
243
|
-
{
|
|
244
|
-
return this.getHitResultFromScreenPoint(this.pointerPosition.x, this.pointerPosition.y)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
getHitResultFromScreenPoint(x: number, y: number): Intersection | null
|
|
248
|
-
{
|
|
249
|
-
this.raycaster.setFromCamera(new Vector2(x, y), this.camera);
|
|
250
|
-
let out = this.raycaster.intersectObjects(this.world.scene.children, true)
|
|
251
|
-
for (let i = 0; i < out.length; i++)
|
|
252
|
-
{
|
|
253
|
-
if (out[i].object.userData["rayIgnored"])
|
|
254
|
-
{
|
|
255
|
-
continue
|
|
256
|
-
}
|
|
257
|
-
return out[i]
|
|
258
|
-
}
|
|
259
|
-
return null
|
|
260
|
-
}
|
|
261
|
-
}
|