@vyr/three 0.0.1
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/package.json +26 -0
- package/src/actor/ComposerServiceActor.ts +107 -0
- package/src/actor/GeometryActor.ts +13 -0
- package/src/actor/HTMLConvertActor.ts +55 -0
- package/src/actor/MaterialActor.ts +13 -0
- package/src/actor/NodeActor.ts +25 -0
- package/src/actor/OrbitControllerActor.ts +110 -0
- package/src/actor/PassActor.ts +24 -0
- package/src/actor/SceneServiceActor.ts +122 -0
- package/src/actor/TextureActor.ts +13 -0
- package/src/actor/TransformControllerActor.ts +23 -0
- package/src/actor/index.ts +10 -0
- package/src/asset/index.ts +187 -0
- package/src/controls/CameraControls.ts +2360 -0
- package/src/controls/TransformControls.ts +1747 -0
- package/src/controls/index.ts +2 -0
- package/src/descriptor/ComposerServiceDescriptor.ts +47 -0
- package/src/descriptor/GeoMapDescriptor.ts +24 -0
- package/src/descriptor/HTMLConvertDescriptor.ts +12 -0
- package/src/descriptor/InstancedMeshDescriptor.ts +21 -0
- package/src/descriptor/MeshDescriptor.ts +16 -0
- package/src/descriptor/ModelDescriptor.ts +15 -0
- package/src/descriptor/OrbitControllerDescriptor.ts +84 -0
- package/src/descriptor/OrthographicCameraDescriptor.ts +12 -0
- package/src/descriptor/ParticleDescriptor.ts +88 -0
- package/src/descriptor/PassDescriptor.ts +33 -0
- package/src/descriptor/PerspectiveCameraDescriptor.ts +15 -0
- package/src/descriptor/PointsDescriptor.ts +16 -0
- package/src/descriptor/SceneServiceDescriptor.ts +39 -0
- package/src/descriptor/SpriteDescriptor.ts +16 -0
- package/src/descriptor/TextDescriptor.ts +41 -0
- package/src/descriptor/TransformControllerDescriptor.ts +32 -0
- package/src/descriptor/animation/AnimationActionDescriptor.ts +52 -0
- package/src/descriptor/geometry/BoxGeometryDescriptor.ts +26 -0
- package/src/descriptor/geometry/BufferGeometryDescriptor.ts +15 -0
- package/src/descriptor/geometry/CircleGeometryDescriptor.ts +22 -0
- package/src/descriptor/geometry/CylinderGeometryDescriptor.ts +30 -0
- package/src/descriptor/geometry/ExtrudeGeometryDescriptor.ts +35 -0
- package/src/descriptor/geometry/GeometryDescriptor.ts +8 -0
- package/src/descriptor/geometry/PlaneGeometryDescriptor.ts +22 -0
- package/src/descriptor/geometry/RingGeometryDescriptor.ts +26 -0
- package/src/descriptor/geometry/SphereGeometryDescriptor.ts +27 -0
- package/src/descriptor/geometry/SurfaceGeometryDescriptor.ts +15 -0
- package/src/descriptor/geometry/TubeGeometryDescriptor.ts +25 -0
- package/src/descriptor/helper/AxesHelperDescriptor.ts +8 -0
- package/src/descriptor/index.ts +45 -0
- package/src/descriptor/light/AmbientLightDescriptor.ts +8 -0
- package/src/descriptor/light/DirectionalLightDescriptor.ts +33 -0
- package/src/descriptor/light/HemisphereLightDescriptor.ts +16 -0
- package/src/descriptor/light/LightDescriptor.ts +16 -0
- package/src/descriptor/light/PointLightDescriptor.ts +24 -0
- package/src/descriptor/light/RectAreaLightDescriptor.ts +20 -0
- package/src/descriptor/light/SpotLightDescriptor.ts +30 -0
- package/src/descriptor/material/MaterialDescriptor.ts +84 -0
- package/src/descriptor/material/MeshBasicMaterialDescriptor.ts +53 -0
- package/src/descriptor/material/MeshPhongMaterialDescriptor.ts +102 -0
- package/src/descriptor/material/MeshStandardMaterialDescriptor.ts +99 -0
- package/src/descriptor/material/PointsMaterialDescriptor.ts +31 -0
- package/src/descriptor/material/ShaderMaterialDescriptor.ts +35 -0
- package/src/descriptor/material/ShadowMaterialDescriptor.ts +19 -0
- package/src/descriptor/material/SpriteMaterialDescriptor.ts +31 -0
- package/src/descriptor/texture/TextureDescriptor.ts +110 -0
- package/src/index.ts +9 -0
- package/src/interpreter/ComposerServiceInterpreter.ts +25 -0
- package/src/interpreter/GeoMapInterpreter.ts +253 -0
- package/src/interpreter/HTMLConvertInterpreter.ts +31 -0
- package/src/interpreter/InstancedMeshInterpreter.ts +76 -0
- package/src/interpreter/MeshInterpreter.ts +25 -0
- package/src/interpreter/ModelInterpreter.ts +61 -0
- package/src/interpreter/NodeInterpreter.ts +65 -0
- package/src/interpreter/OrbitControllerInterpreter.ts +47 -0
- package/src/interpreter/OrthographicCameraInterpreter.ts +13 -0
- package/src/interpreter/ParticleInterpreter.ts +221 -0
- package/src/interpreter/PassInterpreter.ts +43 -0
- package/src/interpreter/PerspectiveCameraInterpreter.ts +33 -0
- package/src/interpreter/PointsInterpreter.ts +61 -0
- package/src/interpreter/SceneServiceInterpreter.ts +119 -0
- package/src/interpreter/ServiceSchedulerInterpreter.ts +23 -0
- package/src/interpreter/SpriteInterpreter.ts +45 -0
- package/src/interpreter/TextInterpreter.ts +76 -0
- package/src/interpreter/TransformControllerInterpreter.ts +44 -0
- package/src/interpreter/animation/AnimationActionInterpreter.ts +66 -0
- package/src/interpreter/geometry/BoxGeometryInterpreter.ts +34 -0
- package/src/interpreter/geometry/BufferGeometryInterpreter.ts +47 -0
- package/src/interpreter/geometry/CircleGeometryInterpreter.ts +34 -0
- package/src/interpreter/geometry/CylinderGeometryInterpreter.ts +34 -0
- package/src/interpreter/geometry/ExtrudeGeometryInterpreter.ts +55 -0
- package/src/interpreter/geometry/PlaneGeometryInterpreter.ts +34 -0
- package/src/interpreter/geometry/RingGeometryInterpreter.ts +34 -0
- package/src/interpreter/geometry/SphereGeometryInterpreter.ts +34 -0
- package/src/interpreter/geometry/SurfaceGeometryInterpreter.ts +39 -0
- package/src/interpreter/geometry/TubeGeometryInterpreter.ts +42 -0
- package/src/interpreter/helper/AxesHelperInterpreter.ts +38 -0
- package/src/interpreter/index.ts +45 -0
- package/src/interpreter/light/AmbientLightInterpreter.ts +30 -0
- package/src/interpreter/light/DirectionalLightInterpreter.ts +84 -0
- package/src/interpreter/light/HemisphereLightInterpreter.ts +32 -0
- package/src/interpreter/light/PointLightInterpreter.ts +46 -0
- package/src/interpreter/light/RectAreaLightInterpreter.ts +34 -0
- package/src/interpreter/light/SpotLightInterpreter.ts +68 -0
- package/src/interpreter/material/MaterialInterpreter.ts +34 -0
- package/src/interpreter/material/MeshBasicMaterialInterpreter.ts +43 -0
- package/src/interpreter/material/MeshPhongMaterialInterpreter.ts +63 -0
- package/src/interpreter/material/MeshStandardMaterialInterpreter.ts +58 -0
- package/src/interpreter/material/PointsMaterialInterpreter.ts +36 -0
- package/src/interpreter/material/ShaderMaterialInterpreter.ts +51 -0
- package/src/interpreter/material/ShadowMaterialInterpreter.ts +31 -0
- package/src/interpreter/material/SpriteMaterialInterpreter.ts +36 -0
- package/src/interpreter/texture/TextureInterpreter.ts +59 -0
- package/src/locale/Language.ts +10 -0
- package/src/locale/LanguageProvider.ts +16 -0
- package/src/locale/index.ts +2 -0
- package/src/preset/execute/GeoMap/drilldown.ts +61 -0
- package/src/preset/execute/GeoMap/index.ts +1 -0
- package/src/preset/execute/index.ts +1 -0
- package/src/preset/index.ts +7 -0
- package/src/preset/routine/GeoMap/drilldown.ts +26 -0
- package/src/preset/routine/GeoMap/index.ts +1 -0
- package/src/preset/routine/index.ts +1 -0
- package/src/utils/dispose/index.ts +23 -0
- package/src/utils/geometry/index.ts +82 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/material/index.ts +53 -0
- package/src/utils/pickup/index.ts +16 -0
- package/src/utils/random/index.ts +7 -0
- package/src/utils/text/index.ts +492 -0
- package/src/utils/texture/index.ts +19 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import { DeserializationObject } from "@vyr/engine"
|
|
3
|
+
import { SceneServiceDescriptor } from "./SceneServiceDescriptor"
|
|
4
|
+
|
|
5
|
+
enum frameBufferType {
|
|
6
|
+
/**默认选择,性能最佳,适合标准动态范围(SDR)渲染 */
|
|
7
|
+
UnsignedByteType = THREE.UnsignedByteType,
|
|
8
|
+
/**HDR渲染推荐,平衡性能与质量,支持Bloom、色调映射等效果 */
|
|
9
|
+
HalfFloatType = THREE.HalfFloatType,
|
|
10
|
+
/**超高精度需求,科学计算、物理模拟等特殊场景 */
|
|
11
|
+
FloatType = THREE.FloatType,
|
|
12
|
+
/**有符号数据,特殊图像处理 */
|
|
13
|
+
ByteType = THREE.ByteType,
|
|
14
|
+
/**16位整数数据,医学影像等 */
|
|
15
|
+
ShortType = THREE.ShortType,
|
|
16
|
+
/**16位无符号数据,深度缓冲区等 */
|
|
17
|
+
UnsignedShortType = THREE.UnsignedShortType,
|
|
18
|
+
/**32位整数数据,特殊计算需求 */
|
|
19
|
+
IntType = THREE.IntType,
|
|
20
|
+
/**32位无符号数据,ID缓冲区、模板缓冲区等 */
|
|
21
|
+
UnsignedIntType = THREE.UnsignedIntType,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class ComposerServiceDescriptor extends SceneServiceDescriptor {
|
|
25
|
+
static type = 'ComposerService'
|
|
26
|
+
|
|
27
|
+
/**采样率 */
|
|
28
|
+
multisampling: number
|
|
29
|
+
/**缓冲帧类型 */
|
|
30
|
+
frameBufferType: frameBufferType
|
|
31
|
+
/**深度缓冲区 */
|
|
32
|
+
depthBuffer: boolean
|
|
33
|
+
/**模板缓冲区 */
|
|
34
|
+
stencilBuffer: boolean
|
|
35
|
+
|
|
36
|
+
constructor(descriptor: Partial<DeserializationObject<ComposerServiceDescriptor>> = {}) {
|
|
37
|
+
super(descriptor)
|
|
38
|
+
this.multisampling = descriptor.multisampling = 2
|
|
39
|
+
this.frameBufferType = descriptor.frameBufferType ?? frameBufferType.UnsignedByteType
|
|
40
|
+
this.depthBuffer = descriptor.depthBuffer ?? true
|
|
41
|
+
this.stencilBuffer = descriptor.stencilBuffer ?? false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
SceneServiceDescriptor.register(ComposerServiceDescriptor)
|
|
46
|
+
|
|
47
|
+
export { ComposerServiceDescriptor }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AssetPropertyCollection, DeserializationObject, NodeDescriptor } from "@vyr/engine"
|
|
2
|
+
|
|
3
|
+
class GeoMapDescriptor extends NodeDescriptor {
|
|
4
|
+
static type = 'GeoMap'
|
|
5
|
+
material: AssetPropertyCollection | string
|
|
6
|
+
borderMaterial: string
|
|
7
|
+
shadowMaterial: string
|
|
8
|
+
geojsonRegion: string
|
|
9
|
+
geojsonBorder: string
|
|
10
|
+
label: string
|
|
11
|
+
|
|
12
|
+
constructor(descriptor: Partial<DeserializationObject<GeoMapDescriptor>> = {}) {
|
|
13
|
+
super(descriptor)
|
|
14
|
+
this.material = Array.isArray(descriptor.material) ? NodeDescriptor.deepClone(descriptor.material) : descriptor.material ?? ''
|
|
15
|
+
this.borderMaterial = descriptor.borderMaterial ?? ''
|
|
16
|
+
this.shadowMaterial = descriptor.shadowMaterial ?? ''
|
|
17
|
+
this.geojsonRegion = descriptor.geojsonRegion ?? ''
|
|
18
|
+
this.geojsonBorder = descriptor.geojsonBorder ?? ''
|
|
19
|
+
this.label = descriptor.label ?? ''
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
NodeDescriptor.register(GeoMapDescriptor)
|
|
23
|
+
|
|
24
|
+
export { GeoMapDescriptor }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DeserializationObject, NodeDescriptor } from "@vyr/engine";
|
|
2
|
+
|
|
3
|
+
class HTMLConvertDescriptor extends NodeDescriptor {
|
|
4
|
+
static type = 'HTMLConvert'
|
|
5
|
+
|
|
6
|
+
constructor(descriptor: Partial<DeserializationObject<HTMLConvertDescriptor>> = {}) {
|
|
7
|
+
super(descriptor)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
NodeDescriptor.register(HTMLConvertDescriptor)
|
|
11
|
+
|
|
12
|
+
export { HTMLConvertDescriptor }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine"
|
|
2
|
+
import { MeshDescriptor } from "./MeshDescriptor"
|
|
3
|
+
|
|
4
|
+
interface InstancedSetting {
|
|
5
|
+
color: string
|
|
6
|
+
matrix: number[]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class InstancedMeshDescriptor extends MeshDescriptor {
|
|
10
|
+
static type = 'InstancedMesh'
|
|
11
|
+
|
|
12
|
+
setting: string
|
|
13
|
+
|
|
14
|
+
constructor(descriptor: Partial<DeserializationObject<InstancedMeshDescriptor>> = {}) {
|
|
15
|
+
super(descriptor)
|
|
16
|
+
this.setting = descriptor.setting ?? ''
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
MeshDescriptor.register(InstancedMeshDescriptor)
|
|
20
|
+
|
|
21
|
+
export { InstancedSetting, InstancedMeshDescriptor }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AssetPropertyCollection, DeserializationObject, NodeDescriptor } from "@vyr/engine"
|
|
2
|
+
|
|
3
|
+
class MeshDescriptor extends NodeDescriptor {
|
|
4
|
+
static type = 'Mesh'
|
|
5
|
+
material: AssetPropertyCollection | string
|
|
6
|
+
geometry: string
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<MeshDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.material = Array.isArray(descriptor.material) ? NodeDescriptor.deepClone(descriptor.material) : descriptor.material ?? ''
|
|
11
|
+
this.geometry = descriptor.geometry ?? ''
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
NodeDescriptor.register(MeshDescriptor)
|
|
15
|
+
|
|
16
|
+
export { MeshDescriptor }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DeserializationObject, NodeDescriptor } from "@vyr/engine";
|
|
2
|
+
|
|
3
|
+
class ModelDescriptor extends NodeDescriptor {
|
|
4
|
+
static type = 'Model'
|
|
5
|
+
|
|
6
|
+
url = ''
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<ModelDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.url = descriptor.url ?? ''
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
NodeDescriptor.register(ModelDescriptor)
|
|
14
|
+
|
|
15
|
+
export { ModelDescriptor }
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ControllerDescriptor, DeserializationObject, UpdateArgs, Vector3 } from "@vyr/engine";
|
|
2
|
+
|
|
3
|
+
interface OrbitControllerChangeArgs extends UpdateArgs {
|
|
4
|
+
event: {
|
|
5
|
+
type: string,
|
|
6
|
+
target: string
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class OrbitControllerDescriptor extends ControllerDescriptor {
|
|
11
|
+
static type = 'OrbitController'
|
|
12
|
+
|
|
13
|
+
/**你能够将相机向内移动多少 */
|
|
14
|
+
minDistance: number
|
|
15
|
+
/**你能够将相机向外移动多少 */
|
|
16
|
+
maxDistance: number
|
|
17
|
+
/**你能够将相机放大多少 */
|
|
18
|
+
minZoom: number
|
|
19
|
+
/**你能够将相机缩小多少 */
|
|
20
|
+
maxZoom: number
|
|
21
|
+
/**你能够垂直旋转的角度的下限 */
|
|
22
|
+
minPolarAngle: number
|
|
23
|
+
/**你能够垂直旋转的角度的上限 */
|
|
24
|
+
maxPolarAngle: number
|
|
25
|
+
/**你能够水平旋转的角度下限 */
|
|
26
|
+
minAzimuthAngle: number
|
|
27
|
+
/**你能够水平旋转的角度上限 */
|
|
28
|
+
maxAzimuthAngle: number
|
|
29
|
+
/**边界摩擦系数 */
|
|
30
|
+
boundaryFriction: number
|
|
31
|
+
/**相机位置是否应包含在边界内 */
|
|
32
|
+
boundaryEnclosesCamera: boolean
|
|
33
|
+
/**到达目标的近似时间(秒),值越小到达目标越快 */
|
|
34
|
+
smoothTime: number
|
|
35
|
+
/**拖动时的平滑时间 */
|
|
36
|
+
draggingSmoothTime: number
|
|
37
|
+
/**水平旋转速度 */
|
|
38
|
+
azimuthRotateSpeed: number
|
|
39
|
+
/**垂直旋转速度 */
|
|
40
|
+
polarRotateSpeed: number
|
|
41
|
+
/**鼠标滚轮移动速度 */
|
|
42
|
+
dollySpeed: number
|
|
43
|
+
/**平移和升降的拖动速度 */
|
|
44
|
+
truckSpeed: number
|
|
45
|
+
/**是否启用向鼠标光标坐标移动 */
|
|
46
|
+
dollyToCursor: boolean
|
|
47
|
+
/**是否反转拖动时的移动或缩放方向 */
|
|
48
|
+
dollyDragInverted: boolean
|
|
49
|
+
/**是否启用滚轮和缩放的无限移动,与 minDistance 和 maxDistance 一起使用³ */
|
|
50
|
+
infinityDolly: boolean
|
|
51
|
+
/**控制相机减速时 rest 事件触发的时机 */
|
|
52
|
+
restThreshold: number
|
|
53
|
+
/**控制器触发事件时执行的脚本依赖 */
|
|
54
|
+
event: string
|
|
55
|
+
|
|
56
|
+
constructor(descriptor: Partial<DeserializationObject<OrbitControllerDescriptor>> = {}) {
|
|
57
|
+
super(descriptor)
|
|
58
|
+
this.minDistance = descriptor.minDistance ?? 0
|
|
59
|
+
this.maxDistance = descriptor.maxDistance ?? Infinity
|
|
60
|
+
this.minPolarAngle = descriptor.minPolarAngle ?? 0
|
|
61
|
+
this.maxPolarAngle = descriptor.maxPolarAngle ?? Math.PI * 2
|
|
62
|
+
this.minAzimuthAngle = descriptor.minAzimuthAngle ?? -Infinity
|
|
63
|
+
this.maxAzimuthAngle = descriptor.maxAzimuthAngle ?? Infinity
|
|
64
|
+
this.minZoom = descriptor.minZoom ?? 0.01
|
|
65
|
+
this.maxZoom = descriptor.maxZoom ?? Infinity
|
|
66
|
+
|
|
67
|
+
this.boundaryFriction = descriptor.boundaryFriction ?? 0
|
|
68
|
+
this.boundaryEnclosesCamera = descriptor.boundaryEnclosesCamera ?? false
|
|
69
|
+
this.smoothTime = descriptor.smoothTime ?? 0.25
|
|
70
|
+
this.draggingSmoothTime = descriptor.draggingSmoothTime ?? 0.125
|
|
71
|
+
this.azimuthRotateSpeed = descriptor.azimuthRotateSpeed ?? 1
|
|
72
|
+
this.polarRotateSpeed = descriptor.polarRotateSpeed ?? 1
|
|
73
|
+
this.dollySpeed = descriptor.dollySpeed ?? 1
|
|
74
|
+
this.truckSpeed = descriptor.truckSpeed ?? 2
|
|
75
|
+
this.dollyToCursor = descriptor.dollyToCursor ?? false
|
|
76
|
+
this.dollyDragInverted = descriptor.dollyDragInverted ?? false
|
|
77
|
+
this.infinityDolly = descriptor.infinityDolly ?? false
|
|
78
|
+
this.restThreshold = descriptor.restThreshold ?? 0.0025
|
|
79
|
+
this.event = descriptor.event ?? ''
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
ControllerDescriptor.register(OrbitControllerDescriptor)
|
|
83
|
+
|
|
84
|
+
export { OrbitControllerChangeArgs, OrbitControllerDescriptor }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CameraDescriptor, DeserializationObject } from "@vyr/engine"
|
|
2
|
+
|
|
3
|
+
class OrthographicCameraDescriptor extends CameraDescriptor {
|
|
4
|
+
static type = 'OrthographicCamera'
|
|
5
|
+
|
|
6
|
+
constructor(descriptor: Partial<DeserializationObject<OrthographicCameraDescriptor>> = {}) {
|
|
7
|
+
super(descriptor)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
CameraDescriptor.register(OrthographicCameraDescriptor)
|
|
11
|
+
|
|
12
|
+
export { OrthographicCameraDescriptor }
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DefaultStyleColor, DeserializationObject, Euler, NodeDescriptor, Vector3 } from "@vyr/engine"
|
|
2
|
+
import { MaterialDepthFunc, MaterialDlending, MaterialSide } from "./material/MaterialDescriptor"
|
|
3
|
+
|
|
4
|
+
class ParticleDescriptor extends NodeDescriptor {
|
|
5
|
+
static type = 'Particle'
|
|
6
|
+
|
|
7
|
+
count: number
|
|
8
|
+
/**粒子轨迹 */
|
|
9
|
+
track: string
|
|
10
|
+
/**粒子运行时间 */
|
|
11
|
+
duration: number
|
|
12
|
+
/**最大粒子尺寸 */
|
|
13
|
+
minSize: number
|
|
14
|
+
/**最大粒子尺寸 */
|
|
15
|
+
maxSize: number
|
|
16
|
+
/**最小轨迹偏移 */
|
|
17
|
+
minTrackOffset: Vector3
|
|
18
|
+
/**最大轨迹偏移 */
|
|
19
|
+
maxTrackOffset: Vector3
|
|
20
|
+
/**最小轨迹缩放 */
|
|
21
|
+
minTrackScale: Vector3
|
|
22
|
+
/**最大轨迹缩放 */
|
|
23
|
+
maxTrackScale: Vector3
|
|
24
|
+
/**最大轨迹旋转 */
|
|
25
|
+
minTrackRotation: Euler
|
|
26
|
+
/**最大轨迹旋转 */
|
|
27
|
+
maxTrackRotation: Euler
|
|
28
|
+
/**透明度测试 */
|
|
29
|
+
alphaTest: number
|
|
30
|
+
/**材质是否透明 */
|
|
31
|
+
transparent: boolean
|
|
32
|
+
/**材质类型 */
|
|
33
|
+
side: number
|
|
34
|
+
/**是否渲染材质的颜色 */
|
|
35
|
+
colorWrite: boolean
|
|
36
|
+
/**是否启用深度测试 */
|
|
37
|
+
depthTest: boolean
|
|
38
|
+
/**是否写入深度 */
|
|
39
|
+
depthrWrite: boolean
|
|
40
|
+
/**深度函数 */
|
|
41
|
+
depthFunc: number
|
|
42
|
+
/** 混合函数,混合效果见 https://threejs.org/examples/#webgl_materials_blending */
|
|
43
|
+
blending: number
|
|
44
|
+
/**是否使用顶点着色 */
|
|
45
|
+
vertexColors: boolean
|
|
46
|
+
/**漫反射颜色 */
|
|
47
|
+
color: DefaultStyleColor
|
|
48
|
+
/**漫反射贴图 */
|
|
49
|
+
map: string
|
|
50
|
+
/**透明度贴图 */
|
|
51
|
+
alphaMap: string
|
|
52
|
+
/**点的大小是否会被相机深度衰减 */
|
|
53
|
+
sizeAttenuation: boolean
|
|
54
|
+
/**材质是否受雾影响。默认为true。 */
|
|
55
|
+
fog: boolean
|
|
56
|
+
|
|
57
|
+
constructor(descriptor: Partial<DeserializationObject<ParticleDescriptor>> = {}) {
|
|
58
|
+
super(descriptor)
|
|
59
|
+
this.count = descriptor.count ?? 0
|
|
60
|
+
this.track = descriptor.track ?? ''
|
|
61
|
+
this.duration = descriptor.duration ?? 0
|
|
62
|
+
this.minSize = descriptor.minSize ?? 1
|
|
63
|
+
this.maxSize = descriptor.maxSize ?? 1
|
|
64
|
+
this.minTrackOffset = Vector3.create(descriptor.minTrackOffset)
|
|
65
|
+
this.maxTrackOffset = Vector3.create(descriptor.maxTrackOffset)
|
|
66
|
+
this.minTrackScale = descriptor.minTrackScale ? Vector3.create(descriptor.minTrackScale) : new Vector3(1, 1, 1)
|
|
67
|
+
this.maxTrackScale = descriptor.maxTrackScale ? Vector3.create(descriptor.maxTrackScale) : new Vector3(1, 1, 1)
|
|
68
|
+
this.minTrackRotation = Euler.create(descriptor.minTrackRotation)
|
|
69
|
+
this.maxTrackRotation = Euler.create(descriptor.maxTrackRotation)
|
|
70
|
+
this.alphaTest = descriptor.alphaTest ?? 0
|
|
71
|
+
this.transparent = descriptor.transparent ?? false
|
|
72
|
+
this.side = descriptor.side ?? MaterialSide.FrontSide
|
|
73
|
+
this.colorWrite = descriptor.colorWrite ?? true
|
|
74
|
+
this.depthTest = descriptor.depthTest ?? true
|
|
75
|
+
this.depthrWrite = descriptor.depthrWrite ?? true
|
|
76
|
+
this.depthFunc = descriptor.depthFunc ?? MaterialDepthFunc.LessEqualDepth
|
|
77
|
+
this.blending = descriptor.blending ?? MaterialDlending.NormalBlending
|
|
78
|
+
this.vertexColors = descriptor.vertexColors ?? false
|
|
79
|
+
this.color = descriptor.color ? new DefaultStyleColor(descriptor.color) : new DefaultStyleColor({ value: '#ffffff' })
|
|
80
|
+
this.map = descriptor.map ?? ''
|
|
81
|
+
this.alphaMap = descriptor.alphaMap ?? ''
|
|
82
|
+
this.sizeAttenuation = descriptor.sizeAttenuation ?? true
|
|
83
|
+
this.fog = descriptor.fog ?? true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
NodeDescriptor.register(ParticleDescriptor)
|
|
87
|
+
|
|
88
|
+
export { ParticleDescriptor }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Descriptor, DeserializationObject } from "@vyr/engine";
|
|
2
|
+
|
|
3
|
+
interface EffectPass {
|
|
4
|
+
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//TODO 继续实现渲染通道
|
|
8
|
+
class PassDescriptor extends Descriptor {
|
|
9
|
+
static type = 'Pass'
|
|
10
|
+
|
|
11
|
+
/**是否启用通道 */
|
|
12
|
+
enabled: boolean
|
|
13
|
+
/**是否需要交换换冲突 */
|
|
14
|
+
needsSwap: boolean
|
|
15
|
+
/**是否需要为此材质准备深度纹理 */
|
|
16
|
+
needsDepthTexture: boolean
|
|
17
|
+
/**该通道的效果 */
|
|
18
|
+
effects: EffectPass[]
|
|
19
|
+
|
|
20
|
+
constructor(descriptor: Partial<DeserializationObject<PassDescriptor>> = {}) {
|
|
21
|
+
super(descriptor)
|
|
22
|
+
this.enabled = descriptor.enabled ?? true
|
|
23
|
+
this.needsSwap = descriptor.needsSwap ?? false
|
|
24
|
+
this.needsDepthTexture = descriptor.needsDepthTexture ?? false
|
|
25
|
+
this.effects = descriptor.effects ? Descriptor.deepClone(descriptor.effects) : []
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Descriptor.register(PassDescriptor)
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
PassDescriptor
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CameraDescriptor, DeserializationObject } from "@vyr/engine"
|
|
2
|
+
|
|
3
|
+
class PerspectiveCameraDescriptor extends CameraDescriptor {
|
|
4
|
+
static type = 'PerspectiveCamera'
|
|
5
|
+
|
|
6
|
+
fov: number
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<PerspectiveCameraDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.fov = descriptor.fov ?? 45
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
CameraDescriptor.register(PerspectiveCameraDescriptor)
|
|
14
|
+
|
|
15
|
+
export { PerspectiveCameraDescriptor }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DeserializationObject, NodeDescriptor } from "@vyr/engine"
|
|
2
|
+
|
|
3
|
+
class PointsDescriptor extends NodeDescriptor {
|
|
4
|
+
static type = 'Points'
|
|
5
|
+
material: string
|
|
6
|
+
geometry: string
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<PointsDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.material = descriptor.material ?? ''
|
|
11
|
+
this.geometry = descriptor.geometry ?? ''
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
NodeDescriptor.register(PointsDescriptor)
|
|
15
|
+
|
|
16
|
+
export { PointsDescriptor }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import { DeserializationObject, ServiceDescriptor } from "@vyr/engine"
|
|
3
|
+
|
|
4
|
+
enum SceneShadow {
|
|
5
|
+
BasicShadowMap = THREE.BasicShadowMap,
|
|
6
|
+
PCFShadowMap = THREE.PCFShadowMap,
|
|
7
|
+
PCFSoftShadowMap = THREE.PCFSoftShadowMap,
|
|
8
|
+
VSMShadowMap = THREE.VSMShadowMap,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class SceneServiceDescriptor extends ServiceDescriptor {
|
|
12
|
+
static type = 'SceneService'
|
|
13
|
+
|
|
14
|
+
/**是否开启阴影贴图 */
|
|
15
|
+
shadowMap: boolean
|
|
16
|
+
/**阴影贴图类型 */
|
|
17
|
+
shadowMapType: SceneShadow
|
|
18
|
+
/**是否自动更新阴影贴图 */
|
|
19
|
+
autoUpdateShadowMap: boolean
|
|
20
|
+
/**背景 */
|
|
21
|
+
background: string
|
|
22
|
+
|
|
23
|
+
constructor(descriptor: Partial<DeserializationObject<SceneServiceDescriptor>> = {}) {
|
|
24
|
+
super(descriptor)
|
|
25
|
+
this.width = descriptor.width ?? 100
|
|
26
|
+
this.wUnit = descriptor.wUnit ?? '%'
|
|
27
|
+
this.height = descriptor.height ?? 100
|
|
28
|
+
this.hUnit = descriptor.hUnit ?? '%'
|
|
29
|
+
this.position = descriptor.position ?? 'absolute'
|
|
30
|
+
this.shadowMap = descriptor.shadowMap ?? true
|
|
31
|
+
this.shadowMapType = descriptor.shadowMapType ?? SceneShadow.BasicShadowMap
|
|
32
|
+
this.autoUpdateShadowMap = descriptor.autoUpdateShadowMap ?? false
|
|
33
|
+
this.background = descriptor.background ?? ''
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
ServiceDescriptor.register(SceneServiceDescriptor)
|
|
38
|
+
|
|
39
|
+
export { SceneShadow, SceneServiceDescriptor }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DeserializationObject, NodeDescriptor, Vector2 } from "@vyr/engine"
|
|
2
|
+
|
|
3
|
+
class SpriteDescriptor extends NodeDescriptor {
|
|
4
|
+
static type = 'Sprite'
|
|
5
|
+
material: string
|
|
6
|
+
center: Vector2
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<SpriteDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.material = descriptor.material ?? ''
|
|
11
|
+
this.center = descriptor.center ? Vector2.create(descriptor.center) : Vector2.create(0.5, 0.5)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
NodeDescriptor.register(SpriteDescriptor)
|
|
15
|
+
|
|
16
|
+
export { SpriteDescriptor }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DeserializationObject, NodeDescriptor } from '@vyr/engine'
|
|
2
|
+
|
|
3
|
+
/**字体几何体
|
|
4
|
+
*
|
|
5
|
+
* 需要将字体文件转为json,在使用时最好对字体文件进行裁剪,只保留需要使用的字符
|
|
6
|
+
*/
|
|
7
|
+
class TextDescriptor extends NodeDescriptor {
|
|
8
|
+
static type = 'Text'
|
|
9
|
+
|
|
10
|
+
font: string
|
|
11
|
+
size: number
|
|
12
|
+
maxWidth: number
|
|
13
|
+
lineHeight: number
|
|
14
|
+
letterSpacing: number
|
|
15
|
+
text: string
|
|
16
|
+
flattenUVsToPlane: boolean
|
|
17
|
+
curveSegments: number
|
|
18
|
+
steps: number
|
|
19
|
+
depth: number
|
|
20
|
+
material: string
|
|
21
|
+
|
|
22
|
+
constructor(descriptor: Partial<DeserializationObject<TextDescriptor>> = {}) {
|
|
23
|
+
super(descriptor)
|
|
24
|
+
this.font = descriptor.font ?? ''
|
|
25
|
+
this.size = descriptor.size ?? 1
|
|
26
|
+
this.maxWidth = descriptor.maxWidth ?? Infinity
|
|
27
|
+
this.lineHeight = descriptor.lineHeight ?? 1.5
|
|
28
|
+
this.letterSpacing = descriptor.letterSpacing ?? 0
|
|
29
|
+
this.text = descriptor.text ?? ''
|
|
30
|
+
this.flattenUVsToPlane = descriptor.flattenUVsToPlane ?? false
|
|
31
|
+
this.curveSegments = descriptor.curveSegments ?? 12
|
|
32
|
+
this.steps = descriptor.steps ?? 1
|
|
33
|
+
this.depth = descriptor.depth ?? 1
|
|
34
|
+
this.material = descriptor.material ?? ''
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
NodeDescriptor.register(TextDescriptor)
|
|
38
|
+
|
|
39
|
+
export { TextDescriptor }
|
|
40
|
+
|
|
41
|
+
//npm install troika-three-text 可以实现更灵活文本效果,并且支持排版效果
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ControllerDescriptor, DeserializationObject, UpdateArgs } from "@vyr/engine";
|
|
2
|
+
|
|
3
|
+
interface TransformControllerChangeArgs extends UpdateArgs {
|
|
4
|
+
event: {
|
|
5
|
+
type: string,
|
|
6
|
+
target: string
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class TransformControllerDescriptor extends ControllerDescriptor {
|
|
11
|
+
static type = 'TransformController'
|
|
12
|
+
|
|
13
|
+
/**控制器的摄像机 */
|
|
14
|
+
camera: string
|
|
15
|
+
/**控制器的模式 */
|
|
16
|
+
mode: string
|
|
17
|
+
/**控制器的目标 */
|
|
18
|
+
target: string
|
|
19
|
+
/**控制器触发事件时执行的脚本依赖 */
|
|
20
|
+
event: string
|
|
21
|
+
|
|
22
|
+
constructor(descriptor: Partial<DeserializationObject<TransformControllerDescriptor>> = {}) {
|
|
23
|
+
super(descriptor)
|
|
24
|
+
this.camera = descriptor.camera ?? ''
|
|
25
|
+
this.mode = descriptor.mode ?? ''
|
|
26
|
+
this.target = descriptor.target ?? ''
|
|
27
|
+
this.event = descriptor.event ?? ''
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
ControllerDescriptor.register(TransformControllerDescriptor)
|
|
31
|
+
|
|
32
|
+
export { TransformControllerChangeArgs, TransformControllerDescriptor }
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import { Descriptor, DeserializationObject } from "@vyr/engine";
|
|
3
|
+
|
|
4
|
+
enum ActionLoop {
|
|
5
|
+
LoopOnce = THREE.LoopOnce,
|
|
6
|
+
LoopRepeat = THREE.LoopRepeat,
|
|
7
|
+
LoopPingPong = THREE.LoopPingPong,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
enum ActionBlendMode {
|
|
11
|
+
NormalAnimationBlendMode = THREE.NormalAnimationBlendMode,
|
|
12
|
+
AdditiveAnimationBlendMode = THREE.AdditiveAnimationBlendMode,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class AnimationActionDescriptor extends Descriptor {
|
|
16
|
+
static type = 'AnimationAction'
|
|
17
|
+
clip: string
|
|
18
|
+
play: boolean
|
|
19
|
+
duration: number
|
|
20
|
+
blendMode: ActionBlendMode
|
|
21
|
+
loop: ActionLoop
|
|
22
|
+
repetitions: number
|
|
23
|
+
startTime: number
|
|
24
|
+
weight: number
|
|
25
|
+
enabled: boolean
|
|
26
|
+
timeScale: number
|
|
27
|
+
zeroSlopeAtEnd: boolean
|
|
28
|
+
zeroSlopeAtStart: boolean
|
|
29
|
+
|
|
30
|
+
constructor(descriptor: Partial<DeserializationObject<AnimationActionDescriptor>> = {}) {
|
|
31
|
+
super(descriptor)
|
|
32
|
+
this.clip = descriptor.clip ?? ''
|
|
33
|
+
this.play = descriptor.play ?? false
|
|
34
|
+
this.duration = descriptor.duration ?? -1
|
|
35
|
+
this.blendMode = descriptor.blendMode ?? ActionBlendMode.NormalAnimationBlendMode
|
|
36
|
+
this.loop = descriptor.loop ?? ActionLoop.LoopRepeat
|
|
37
|
+
this.repetitions = descriptor.repetitions ?? Infinity
|
|
38
|
+
this.startTime = descriptor.startTime ?? 0
|
|
39
|
+
this.weight = descriptor.weight ?? 1
|
|
40
|
+
this.enabled = descriptor.enabled ?? true
|
|
41
|
+
this.timeScale = descriptor.timeScale ?? 1
|
|
42
|
+
this.zeroSlopeAtEnd = descriptor.zeroSlopeAtEnd ?? true
|
|
43
|
+
this.zeroSlopeAtStart = descriptor.zeroSlopeAtStart ?? true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
Descriptor.register(AnimationActionDescriptor)
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
ActionLoop,
|
|
50
|
+
ActionBlendMode,
|
|
51
|
+
AnimationActionDescriptor
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DeserializationObject } from '@vyr/engine'
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
/**立方体 */
|
|
5
|
+
class BoxGeometryDescriptor extends GeometryDescriptor {
|
|
6
|
+
static type = 'BoxGeometry'
|
|
7
|
+
width: number
|
|
8
|
+
height: number
|
|
9
|
+
depth: number
|
|
10
|
+
widthSegments: number
|
|
11
|
+
heightSegments: number
|
|
12
|
+
depthSegments: number
|
|
13
|
+
|
|
14
|
+
constructor(descriptor: Partial<DeserializationObject<BoxGeometryDescriptor>> = {}) {
|
|
15
|
+
super(descriptor)
|
|
16
|
+
this.width = descriptor.width ?? 1
|
|
17
|
+
this.height = descriptor.height ?? 1
|
|
18
|
+
this.depth = descriptor.depth ?? 1
|
|
19
|
+
this.widthSegments = descriptor.widthSegments ?? 1
|
|
20
|
+
this.heightSegments = descriptor.heightSegments ?? 1
|
|
21
|
+
this.depthSegments = descriptor.depthSegments ?? 1
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
GeometryDescriptor.register(BoxGeometryDescriptor)
|
|
25
|
+
|
|
26
|
+
export { BoxGeometryDescriptor }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DeserializationObject } from '@vyr/engine'
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
class BufferGeometryDescriptor extends GeometryDescriptor {
|
|
5
|
+
static type = 'BufferGeometry'
|
|
6
|
+
buffer: string
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<BufferGeometryDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.buffer = descriptor.buffer ?? ''
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
GeometryDescriptor.register(BufferGeometryDescriptor)
|
|
14
|
+
|
|
15
|
+
export { BufferGeometryDescriptor }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DeserializationObject } from '@vyr/engine'
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
/**圆形 */
|
|
5
|
+
class CircleGeometryDescriptor extends GeometryDescriptor {
|
|
6
|
+
static type = 'CircleGeometry'
|
|
7
|
+
radius: number
|
|
8
|
+
segments: number
|
|
9
|
+
thetaStart: number
|
|
10
|
+
thetaLength: number
|
|
11
|
+
|
|
12
|
+
constructor(descriptor: Partial<DeserializationObject<CircleGeometryDescriptor>> = {}) {
|
|
13
|
+
super(descriptor)
|
|
14
|
+
this.radius = descriptor.radius ?? 1
|
|
15
|
+
this.segments = descriptor.segments ?? 32
|
|
16
|
+
this.thetaStart = descriptor.thetaStart ?? 0
|
|
17
|
+
this.thetaLength = descriptor.thetaLength ?? Math.PI * 2
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
GeometryDescriptor.register(CircleGeometryDescriptor)
|
|
21
|
+
|
|
22
|
+
export { CircleGeometryDescriptor }
|