@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.
Files changed (127) hide show
  1. package/package.json +26 -0
  2. package/src/actor/ComposerServiceActor.ts +107 -0
  3. package/src/actor/GeometryActor.ts +13 -0
  4. package/src/actor/HTMLConvertActor.ts +55 -0
  5. package/src/actor/MaterialActor.ts +13 -0
  6. package/src/actor/NodeActor.ts +25 -0
  7. package/src/actor/OrbitControllerActor.ts +110 -0
  8. package/src/actor/PassActor.ts +24 -0
  9. package/src/actor/SceneServiceActor.ts +122 -0
  10. package/src/actor/TextureActor.ts +13 -0
  11. package/src/actor/TransformControllerActor.ts +23 -0
  12. package/src/actor/index.ts +10 -0
  13. package/src/asset/index.ts +187 -0
  14. package/src/controls/CameraControls.ts +2360 -0
  15. package/src/controls/TransformControls.ts +1747 -0
  16. package/src/controls/index.ts +2 -0
  17. package/src/descriptor/ComposerServiceDescriptor.ts +47 -0
  18. package/src/descriptor/GeoMapDescriptor.ts +24 -0
  19. package/src/descriptor/HTMLConvertDescriptor.ts +12 -0
  20. package/src/descriptor/InstancedMeshDescriptor.ts +21 -0
  21. package/src/descriptor/MeshDescriptor.ts +16 -0
  22. package/src/descriptor/ModelDescriptor.ts +15 -0
  23. package/src/descriptor/OrbitControllerDescriptor.ts +84 -0
  24. package/src/descriptor/OrthographicCameraDescriptor.ts +12 -0
  25. package/src/descriptor/ParticleDescriptor.ts +88 -0
  26. package/src/descriptor/PassDescriptor.ts +33 -0
  27. package/src/descriptor/PerspectiveCameraDescriptor.ts +15 -0
  28. package/src/descriptor/PointsDescriptor.ts +16 -0
  29. package/src/descriptor/SceneServiceDescriptor.ts +39 -0
  30. package/src/descriptor/SpriteDescriptor.ts +16 -0
  31. package/src/descriptor/TextDescriptor.ts +41 -0
  32. package/src/descriptor/TransformControllerDescriptor.ts +32 -0
  33. package/src/descriptor/animation/AnimationActionDescriptor.ts +52 -0
  34. package/src/descriptor/geometry/BoxGeometryDescriptor.ts +26 -0
  35. package/src/descriptor/geometry/BufferGeometryDescriptor.ts +15 -0
  36. package/src/descriptor/geometry/CircleGeometryDescriptor.ts +22 -0
  37. package/src/descriptor/geometry/CylinderGeometryDescriptor.ts +30 -0
  38. package/src/descriptor/geometry/ExtrudeGeometryDescriptor.ts +35 -0
  39. package/src/descriptor/geometry/GeometryDescriptor.ts +8 -0
  40. package/src/descriptor/geometry/PlaneGeometryDescriptor.ts +22 -0
  41. package/src/descriptor/geometry/RingGeometryDescriptor.ts +26 -0
  42. package/src/descriptor/geometry/SphereGeometryDescriptor.ts +27 -0
  43. package/src/descriptor/geometry/SurfaceGeometryDescriptor.ts +15 -0
  44. package/src/descriptor/geometry/TubeGeometryDescriptor.ts +25 -0
  45. package/src/descriptor/helper/AxesHelperDescriptor.ts +8 -0
  46. package/src/descriptor/index.ts +45 -0
  47. package/src/descriptor/light/AmbientLightDescriptor.ts +8 -0
  48. package/src/descriptor/light/DirectionalLightDescriptor.ts +33 -0
  49. package/src/descriptor/light/HemisphereLightDescriptor.ts +16 -0
  50. package/src/descriptor/light/LightDescriptor.ts +16 -0
  51. package/src/descriptor/light/PointLightDescriptor.ts +24 -0
  52. package/src/descriptor/light/RectAreaLightDescriptor.ts +20 -0
  53. package/src/descriptor/light/SpotLightDescriptor.ts +30 -0
  54. package/src/descriptor/material/MaterialDescriptor.ts +84 -0
  55. package/src/descriptor/material/MeshBasicMaterialDescriptor.ts +53 -0
  56. package/src/descriptor/material/MeshPhongMaterialDescriptor.ts +102 -0
  57. package/src/descriptor/material/MeshStandardMaterialDescriptor.ts +99 -0
  58. package/src/descriptor/material/PointsMaterialDescriptor.ts +31 -0
  59. package/src/descriptor/material/ShaderMaterialDescriptor.ts +35 -0
  60. package/src/descriptor/material/ShadowMaterialDescriptor.ts +19 -0
  61. package/src/descriptor/material/SpriteMaterialDescriptor.ts +31 -0
  62. package/src/descriptor/texture/TextureDescriptor.ts +110 -0
  63. package/src/index.ts +9 -0
  64. package/src/interpreter/ComposerServiceInterpreter.ts +25 -0
  65. package/src/interpreter/GeoMapInterpreter.ts +253 -0
  66. package/src/interpreter/HTMLConvertInterpreter.ts +31 -0
  67. package/src/interpreter/InstancedMeshInterpreter.ts +76 -0
  68. package/src/interpreter/MeshInterpreter.ts +25 -0
  69. package/src/interpreter/ModelInterpreter.ts +61 -0
  70. package/src/interpreter/NodeInterpreter.ts +65 -0
  71. package/src/interpreter/OrbitControllerInterpreter.ts +47 -0
  72. package/src/interpreter/OrthographicCameraInterpreter.ts +13 -0
  73. package/src/interpreter/ParticleInterpreter.ts +221 -0
  74. package/src/interpreter/PassInterpreter.ts +43 -0
  75. package/src/interpreter/PerspectiveCameraInterpreter.ts +33 -0
  76. package/src/interpreter/PointsInterpreter.ts +61 -0
  77. package/src/interpreter/SceneServiceInterpreter.ts +119 -0
  78. package/src/interpreter/ServiceSchedulerInterpreter.ts +23 -0
  79. package/src/interpreter/SpriteInterpreter.ts +45 -0
  80. package/src/interpreter/TextInterpreter.ts +76 -0
  81. package/src/interpreter/TransformControllerInterpreter.ts +44 -0
  82. package/src/interpreter/animation/AnimationActionInterpreter.ts +66 -0
  83. package/src/interpreter/geometry/BoxGeometryInterpreter.ts +34 -0
  84. package/src/interpreter/geometry/BufferGeometryInterpreter.ts +47 -0
  85. package/src/interpreter/geometry/CircleGeometryInterpreter.ts +34 -0
  86. package/src/interpreter/geometry/CylinderGeometryInterpreter.ts +34 -0
  87. package/src/interpreter/geometry/ExtrudeGeometryInterpreter.ts +55 -0
  88. package/src/interpreter/geometry/PlaneGeometryInterpreter.ts +34 -0
  89. package/src/interpreter/geometry/RingGeometryInterpreter.ts +34 -0
  90. package/src/interpreter/geometry/SphereGeometryInterpreter.ts +34 -0
  91. package/src/interpreter/geometry/SurfaceGeometryInterpreter.ts +39 -0
  92. package/src/interpreter/geometry/TubeGeometryInterpreter.ts +42 -0
  93. package/src/interpreter/helper/AxesHelperInterpreter.ts +38 -0
  94. package/src/interpreter/index.ts +45 -0
  95. package/src/interpreter/light/AmbientLightInterpreter.ts +30 -0
  96. package/src/interpreter/light/DirectionalLightInterpreter.ts +84 -0
  97. package/src/interpreter/light/HemisphereLightInterpreter.ts +32 -0
  98. package/src/interpreter/light/PointLightInterpreter.ts +46 -0
  99. package/src/interpreter/light/RectAreaLightInterpreter.ts +34 -0
  100. package/src/interpreter/light/SpotLightInterpreter.ts +68 -0
  101. package/src/interpreter/material/MaterialInterpreter.ts +34 -0
  102. package/src/interpreter/material/MeshBasicMaterialInterpreter.ts +43 -0
  103. package/src/interpreter/material/MeshPhongMaterialInterpreter.ts +63 -0
  104. package/src/interpreter/material/MeshStandardMaterialInterpreter.ts +58 -0
  105. package/src/interpreter/material/PointsMaterialInterpreter.ts +36 -0
  106. package/src/interpreter/material/ShaderMaterialInterpreter.ts +51 -0
  107. package/src/interpreter/material/ShadowMaterialInterpreter.ts +31 -0
  108. package/src/interpreter/material/SpriteMaterialInterpreter.ts +36 -0
  109. package/src/interpreter/texture/TextureInterpreter.ts +59 -0
  110. package/src/locale/Language.ts +10 -0
  111. package/src/locale/LanguageProvider.ts +16 -0
  112. package/src/locale/index.ts +2 -0
  113. package/src/preset/execute/GeoMap/drilldown.ts +61 -0
  114. package/src/preset/execute/GeoMap/index.ts +1 -0
  115. package/src/preset/execute/index.ts +1 -0
  116. package/src/preset/index.ts +7 -0
  117. package/src/preset/routine/GeoMap/drilldown.ts +26 -0
  118. package/src/preset/routine/GeoMap/index.ts +1 -0
  119. package/src/preset/routine/index.ts +1 -0
  120. package/src/utils/dispose/index.ts +23 -0
  121. package/src/utils/geometry/index.ts +82 -0
  122. package/src/utils/index.ts +7 -0
  123. package/src/utils/material/index.ts +53 -0
  124. package/src/utils/pickup/index.ts +16 -0
  125. package/src/utils/random/index.ts +7 -0
  126. package/src/utils/text/index.ts +492 -0
  127. package/src/utils/texture/index.ts +19 -0
@@ -0,0 +1,34 @@
1
+ import { BufferGeometry, SphereGeometry } from "three";
2
+ import { Interpreter, UpdateArgs } from "@vyr/engine";
3
+ import { SphereGeometryDescriptor } from "../../descriptor";
4
+ import { GeometryActor } from "../../actor";
5
+
6
+ class SphereGeometryInterpreter extends Interpreter {
7
+ static type = SphereGeometryDescriptor.type
8
+
9
+ protected createActor(descriptor: SphereGeometryDescriptor, args: UpdateArgs) {
10
+ const actor = new GeometryActor(new BufferGeometry())
11
+ return actor
12
+ }
13
+
14
+ setAttribute(actor: GeometryActor<SphereGeometry>, descriptor: SphereGeometryDescriptor) {
15
+ const source = new SphereGeometry(descriptor.radius, descriptor.widthSegments, descriptor.heightSegments, descriptor.phiStart, descriptor.phiLength, descriptor.thetaStart, descriptor.thetaLength)
16
+ actor.object.copy(source)
17
+ source.dispose()
18
+ }
19
+
20
+ update(descriptor: SphereGeometryDescriptor, args: UpdateArgs) {
21
+ super.update(descriptor, args)
22
+ const actor = this.getActor<GeometryActor<SphereGeometry>>(descriptor, args)
23
+ this.setAttribute(actor, descriptor)
24
+ }
25
+
26
+ free(descriptor: SphereGeometryDescriptor, args: UpdateArgs) {
27
+ const actor = this.getActor<GeometryActor<SphereGeometry>>(descriptor, args)
28
+ actor.object.dispose()
29
+ super.free(descriptor, args)
30
+ }
31
+ }
32
+ Interpreter.register(SphereGeometryInterpreter)
33
+
34
+ export { SphereGeometryInterpreter }
@@ -0,0 +1,39 @@
1
+ import { ExtrudeGeometry, Spherical, Vector3 } from "three";
2
+ import { UpdateArgs } from "@vyr/engine";
3
+ import { SurfaceGeometryDescriptor } from "../../descriptor";
4
+ import { GeometryActor } from "../../actor";
5
+ import { ExtrudeGeometryInterpreter } from "./ExtrudeGeometryInterpreter";
6
+
7
+ class SurfaceGeometryInterpreter extends ExtrudeGeometryInterpreter {
8
+ static type = SurfaceGeometryDescriptor.type
9
+ /**
10
+ * 经纬度转V3
11
+ * @param lng 经度
12
+ * @param lat 纬度
13
+ * @param radius 半径
14
+ */
15
+ static lnglatToV3(lng: number, lat: number, radius: number) {
16
+ const theta = (90 + lng) * (Math.PI / 180)
17
+
18
+ const phi = (90 - lat) * (Math.PI / 180)
19
+
20
+ return new Vector3().setFromSpherical(new Spherical(radius, phi, theta))
21
+ }
22
+
23
+ setAttribute(actor: GeometryActor<ExtrudeGeometry>, descriptor: SurfaceGeometryDescriptor, args: UpdateArgs) {
24
+ super.setAttribute(actor, descriptor, args)
25
+ const position = actor.object.getAttribute('position')
26
+ for (let i = 0; i < position.count; i++) {
27
+ const v = SurfaceGeometryInterpreter.lnglatToV3(
28
+ position.getX(i),
29
+ position.getY(i),
30
+ position.getZ(i) + descriptor.radius
31
+ )
32
+ position.setXYZ(i, v.x, v.y, v.z)
33
+ }
34
+ actor.object.computeVertexNormals()
35
+ }
36
+ }
37
+ ExtrudeGeometryInterpreter.register(SurfaceGeometryInterpreter)
38
+
39
+ export { SurfaceGeometryInterpreter }
@@ -0,0 +1,42 @@
1
+ import { BufferGeometry, CatmullRomCurve3, TubeGeometry, Vector3, } from "three";
2
+ import { DatasetDescriptor, Interpreter, JsonAsset, UpdateArgs } from "@vyr/engine";
3
+ import { TubeGeometryDescriptor } from "../../descriptor";
4
+ import { GeometryActor } from "../../actor";
5
+ import { geometry } from "../../utils";
6
+
7
+ class TubeGeometryInterpreter extends Interpreter {
8
+ static type = TubeGeometryDescriptor.type
9
+
10
+ protected createActor(descriptor: TubeGeometryDescriptor, args: UpdateArgs) {
11
+ const actor = new GeometryActor(new BufferGeometry())
12
+ return actor
13
+ }
14
+
15
+ createPath(line: JsonAsset, descriptor: TubeGeometryDescriptor) {
16
+ const points = geometry.getPointsOfLineData(line, descriptor.offset)
17
+ return new CatmullRomCurve3(points, false)
18
+ }
19
+
20
+ setAttribute(actor: GeometryActor<TubeGeometry>, descriptor: TubeGeometryDescriptor, args: UpdateArgs) {
21
+ const data = DatasetDescriptor.getCollection<number[]>(descriptor.track)
22
+ const path = data.length === 0 ? new CatmullRomCurve3([new Vector3(), new Vector3()]) : this.createPath(data, descriptor)
23
+ const source = new TubeGeometry(path, descriptor.tubularSegments, descriptor.radius, descriptor.radialSegments, descriptor.closed)
24
+ actor.object.copy(source)
25
+ source.dispose()
26
+ }
27
+
28
+ update(descriptor: TubeGeometryDescriptor, args: UpdateArgs) {
29
+ super.update(descriptor, args)
30
+ const actor = this.getActor<GeometryActor<TubeGeometry>>(descriptor, args)
31
+ this.setAttribute(actor, descriptor, args)
32
+ }
33
+
34
+ free(descriptor: TubeGeometryDescriptor, args: UpdateArgs) {
35
+ const actor = this.getActor<GeometryActor<TubeGeometry>>(descriptor, args)
36
+ actor.object.dispose()
37
+ super.free(descriptor, args)
38
+ }
39
+ }
40
+ Interpreter.register(TubeGeometryInterpreter)
41
+
42
+ export { TubeGeometryInterpreter }
@@ -0,0 +1,38 @@
1
+ import { AxesHelper } from 'three'
2
+ import { UpdateArgs } from "@vyr/engine";
3
+ import { AxesHelperDescriptor } from "../../descriptor";
4
+ import { NodeInterpreter } from "../NodeInterpreter";
5
+ import { NodeActor } from '../../actor';
6
+
7
+ class AxesHelperInterpreter extends NodeInterpreter {
8
+ static type = AxesHelperDescriptor.type
9
+
10
+ protected createActor(descriptor: AxesHelperDescriptor, args: UpdateArgs) {
11
+ const actor = new NodeActor(new AxesHelper())
12
+ return actor
13
+ }
14
+
15
+ setAxesHelper(actor: NodeActor<AxesHelper>, descriptor: AxesHelperDescriptor) {
16
+ const size = 1000000
17
+ actor.object.scale.set(size, size, size)
18
+ if (Array.isArray(actor.object.material) === false) {
19
+ actor.object.material.depthTest = false
20
+ actor.object.material.depthWrite = false
21
+ }
22
+ }
23
+
24
+ update(descriptor: AxesHelperDescriptor, args: UpdateArgs) {
25
+ super.update(descriptor, args)
26
+ const actor = this.getActor<NodeActor<AxesHelper>>(descriptor, args)
27
+ this.setAxesHelper(actor, descriptor)
28
+ }
29
+
30
+ free(descriptor: AxesHelperDescriptor, args: UpdateArgs) {
31
+ const actor = this.getActor<NodeActor<AxesHelper>>(descriptor, args)
32
+ actor.object.dispose()
33
+ super.free(descriptor, args)
34
+ }
35
+ }
36
+ NodeInterpreter.register(AxesHelperInterpreter)
37
+
38
+ export { AxesHelperInterpreter }
@@ -0,0 +1,45 @@
1
+ export * from "./geometry/BoxGeometryInterpreter";
2
+ export * from "./geometry/CircleGeometryInterpreter";
3
+ export * from "./geometry/CylinderGeometryInterpreter";
4
+ export * from "./geometry/PlaneGeometryInterpreter";
5
+ export * from "./geometry/RingGeometryInterpreter";
6
+ export * from "./geometry/SphereGeometryInterpreter";
7
+ export * from "./geometry/ExtrudeGeometryInterpreter";
8
+ export * from "./geometry/SurfaceGeometryInterpreter";
9
+ export * from "./geometry/TubeGeometryInterpreter";
10
+ export * from "./geometry/BufferGeometryInterpreter";
11
+ export * from "./material/MaterialInterpreter";
12
+ export * from "./material/MeshBasicMaterialInterpreter";
13
+ export * from "./material/MeshPhongMaterialInterpreter";
14
+ export * from "./material/MeshStandardMaterialInterpreter";
15
+ export * from "./material/PointsMaterialInterpreter";
16
+ export * from "./material/SpriteMaterialInterpreter";
17
+ export * from "./material/ShadowMaterialInterpreter";
18
+ export * from "./material/ShaderMaterialInterpreter";
19
+ export * from './animation/AnimationActionInterpreter'
20
+ export * from "./light/AmbientLightInterpreter";
21
+ export * from "./light/DirectionalLightInterpreter";
22
+ export * from "./light/HemisphereLightInterpreter";
23
+ export * from "./light/PointLightInterpreter";
24
+ export * from "./light/RectAreaLightInterpreter";
25
+ export * from "./light/SpotLightInterpreter";
26
+ export * from "./texture/TextureInterpreter";
27
+ export * from './helper/AxesHelperInterpreter'
28
+ export * from "./ServiceSchedulerInterpreter";
29
+ export * from "./SceneServiceInterpreter";
30
+ export * from "./NodeInterpreter";
31
+ export * from "./MeshInterpreter";
32
+ export * from './InstancedMeshInterpreter'
33
+ export * from './TextInterpreter'
34
+ export * from "./PointsInterpreter";
35
+ export * from './ParticleInterpreter'
36
+ export * from "./SpriteInterpreter";
37
+ export * from './ModelInterpreter'
38
+ export * from './HTMLConvertInterpreter'
39
+ export * from './GeoMapInterpreter'
40
+ export * from "./PerspectiveCameraInterpreter";
41
+ export * from "./OrthographicCameraInterpreter";
42
+ export * from "./OrbitControllerInterpreter";
43
+ export * from "./TransformControllerInterpreter";
44
+ // export * from './ComposerServiceInterpreter'
45
+ // export * from './PassInterpreter'
@@ -0,0 +1,30 @@
1
+ import { AmbientLight } from "three";
2
+ import { PickupObject, UpdateArgs } from "@vyr/engine";
3
+ import { NodeInterpreter } from "../NodeInterpreter";
4
+ import { AmbientLightDescriptor } from "../../descriptor";
5
+ import { NodeActor } from "../../actor";
6
+
7
+ class AmbientLightInterpreter extends NodeInterpreter {
8
+ static type = AmbientLightDescriptor.type
9
+
10
+ protected createActor(descriptor: AmbientLightDescriptor, args: UpdateArgs) {
11
+ const actor = new NodeActor(new AmbientLight())
12
+ return actor
13
+ }
14
+
15
+ setLight(actor: NodeActor<AmbientLight>, descriptor: AmbientLightDescriptor, args: UpdateArgs) {
16
+ actor.object.color.set(descriptor.color)
17
+ actor.object.intensity = descriptor.intensity
18
+ }
19
+
20
+ update(descriptor: AmbientLightDescriptor, args: UpdateArgs) {
21
+ super.update(descriptor, args)
22
+ const actor = this.getActor<NodeActor<AmbientLight>>(descriptor, args)
23
+ this.setLight(actor, descriptor, args)
24
+ }
25
+
26
+ pickup(descriptor: AmbientLightDescriptor, args: UpdateArgs, result: PickupObject[]) { }
27
+ }
28
+ NodeInterpreter.register(AmbientLightInterpreter)
29
+
30
+ export { AmbientLightInterpreter }
@@ -0,0 +1,84 @@
1
+ import { DirectionalLight, Object3D } from "three";
2
+ import { Descriptor, PickupObject, UpdateArgs } from "@vyr/engine";
3
+ import { NodeInterpreter } from "../NodeInterpreter";
4
+ import { DirectionalLightDescriptor } from "../../descriptor";
5
+ import { NodeActor } from "../../actor";
6
+
7
+ class DirectionalLightInterpreter extends NodeInterpreter {
8
+ static type = DirectionalLightDescriptor.type
9
+
10
+ target: Object3D | null = null
11
+
12
+ protected createActor(descriptor: DirectionalLightDescriptor, args: UpdateArgs) {
13
+ const actor = new NodeActor(new DirectionalLight())
14
+ return actor
15
+ }
16
+
17
+ setLight(actor: NodeActor<DirectionalLight>, descriptor: DirectionalLightDescriptor, args: UpdateArgs) {
18
+ actor.object.color.set(descriptor.color)
19
+ actor.object.intensity = descriptor.intensity
20
+ actor.object.shadow.bias = descriptor.bias
21
+ actor.object.shadow.normalBias = descriptor.normalBias
22
+
23
+ const mapSize = descriptor.mapSize
24
+ actor.object.shadow.mapSize.set(mapSize.x, mapSize.y)
25
+ if (actor.object.shadow.mapPass) {
26
+ actor.object.shadow.mapPass.setSize(mapSize.x, mapSize.y)
27
+ actor.object.shadow.mapPass.texture.needsUpdate = true
28
+ }
29
+ if (actor.object.shadow.map) {
30
+ actor.object.shadow.map.setSize(mapSize.x, mapSize.y)
31
+ actor.object.shadow.map.texture.needsUpdate = true
32
+ }
33
+
34
+ const camera = descriptor.camera
35
+ actor.object.shadow.camera.near = camera.near
36
+ actor.object.shadow.camera.far = camera.far
37
+ actor.object.shadow.camera.left = camera.left
38
+ actor.object.shadow.camera.right = camera.right
39
+ actor.object.shadow.camera.top = camera.top
40
+ actor.object.shadow.camera.bottom = camera.bottom
41
+ actor.object.shadow.camera.updateProjectionMatrix()
42
+ }
43
+
44
+ setTarget(actor: NodeActor<DirectionalLight>, descriptor: DirectionalLightDescriptor, args: UpdateArgs) {
45
+ let targetValue = descriptor.target
46
+ if (targetValue === '') {
47
+ const target = new Object3D()
48
+ target.position.copy(actor.object.target.position)
49
+ actor.object.target = target
50
+ } else {
51
+ const target = Descriptor.get<Descriptor>(targetValue)
52
+ if (target !== null) {
53
+ const targetActor = this.graphics.getActor<NodeActor>(target, args)
54
+ if (targetActor instanceof NodeActor) {
55
+ actor.object.target = targetActor.object
56
+ } else {
57
+ actor.object.target = new Object3D()
58
+ }
59
+ } else {
60
+ actor.object.target = new Object3D()
61
+ }
62
+
63
+ }
64
+
65
+ }
66
+
67
+ update(descriptor: DirectionalLightDescriptor, args: UpdateArgs) {
68
+ super.update(descriptor, args)
69
+ const actor = this.getActor<NodeActor<DirectionalLight>>(descriptor, args)
70
+ this.setLight(actor, descriptor, args)
71
+ this.setTarget(actor, descriptor, args)
72
+ }
73
+
74
+ free(descriptor: DirectionalLightDescriptor, args: UpdateArgs) {
75
+ const actor = this.getActor<NodeActor<DirectionalLight>>(descriptor, args)
76
+ actor.object.dispose()
77
+ super.free(descriptor, args)
78
+ }
79
+
80
+ pickup(descriptor: DirectionalLightDescriptor, args: UpdateArgs, result: PickupObject[]) { }
81
+ }
82
+ NodeInterpreter.register(DirectionalLightInterpreter)
83
+
84
+ export { DirectionalLightInterpreter }
@@ -0,0 +1,32 @@
1
+ import { HemisphereLight } from "three";
2
+ import { PickupObject, UpdateArgs } from "@vyr/engine";
3
+ import { NodeInterpreter } from "../NodeInterpreter";
4
+ import { HemisphereLightDescriptor } from "../../descriptor";
5
+ import { NodeActor } from "../../actor";
6
+
7
+ class HemisphereLightInterpreter extends NodeInterpreter {
8
+ static type = HemisphereLightDescriptor.type
9
+
10
+ protected createActor(descriptor: HemisphereLightDescriptor, args: UpdateArgs) {
11
+ const actor = new NodeActor(new HemisphereLight())
12
+ return actor
13
+ }
14
+
15
+ setLight(actor: NodeActor<HemisphereLight>, descriptor: HemisphereLightDescriptor, args: UpdateArgs) {
16
+ actor.object.color.set(descriptor.color)
17
+ actor.object.intensity = descriptor.intensity
18
+ actor.object.groundColor.set(descriptor.groundColor)
19
+ }
20
+
21
+ update(descriptor: HemisphereLightDescriptor, args: UpdateArgs) {
22
+ super.update(descriptor, args)
23
+ const actor = this.getActor<NodeActor<HemisphereLight>>(descriptor, args)
24
+ this.setLight(actor, descriptor, args)
25
+ }
26
+
27
+ pickup(descriptor: HemisphereLightDescriptor, args: UpdateArgs, result: PickupObject[]) { }
28
+ }
29
+ NodeInterpreter.register(HemisphereLightInterpreter)
30
+
31
+
32
+ export { HemisphereLightInterpreter }
@@ -0,0 +1,46 @@
1
+ import { PointLight } from "three";
2
+ import { PickupObject, UpdateArgs } from "@vyr/engine";
3
+ import { NodeInterpreter } from "../NodeInterpreter";
4
+ import { PointLightDescriptor } from "../../descriptor";
5
+ import { NodeActor } from "../../actor";
6
+
7
+ class PointLightInterpreter extends NodeInterpreter {
8
+ static type = PointLightDescriptor.type
9
+
10
+ protected createActor(descriptor: PointLightDescriptor, args: UpdateArgs) {
11
+ const actor = new NodeActor(new PointLight())
12
+ return actor
13
+ }
14
+
15
+ setLight(actor: NodeActor<PointLight>, descriptor: PointLightDescriptor, args: UpdateArgs) {
16
+ actor.object.color.set(descriptor.color)
17
+ actor.object.intensity = descriptor.intensity
18
+ actor.object.decay = descriptor.decay
19
+ actor.object.distance = descriptor.distance
20
+ actor.object.power = descriptor.power
21
+ const mapSize = descriptor.mapSize
22
+ const camera = descriptor.camera
23
+ actor.object.shadow.mapSize.set(mapSize.x, mapSize.y)
24
+ actor.object.shadow.camera.near = camera.near
25
+ actor.object.shadow.camera.far = camera.far
26
+ }
27
+
28
+
29
+ update(descriptor: PointLightDescriptor, args: UpdateArgs) {
30
+ super.update(descriptor, args)
31
+ const actor = this.getActor<NodeActor<PointLight>>(descriptor, args)
32
+ this.setLight(actor, descriptor, args)
33
+ }
34
+
35
+ free(descriptor: PointLightDescriptor, args: UpdateArgs) {
36
+ const actor = this.getActor<NodeActor<PointLight>>(descriptor, args)
37
+ actor.object.dispose()
38
+ super.free(descriptor, args)
39
+ }
40
+
41
+ pickup(descriptor: PointLightDescriptor, args: UpdateArgs, result: PickupObject[]) { }
42
+ }
43
+ NodeInterpreter.register(PointLightInterpreter)
44
+
45
+
46
+ export { PointLightInterpreter }
@@ -0,0 +1,34 @@
1
+ import { RectAreaLight } from "three";
2
+ import { PickupObject, UpdateArgs } from "@vyr/engine";
3
+ import { NodeInterpreter } from "../NodeInterpreter";
4
+ import { RectAreaLightDescriptor } from "../../descriptor";
5
+ import { NodeActor } from "../../actor";
6
+
7
+ class RectAreaLightInterpreter extends NodeInterpreter {
8
+ static type = RectAreaLightDescriptor.type
9
+
10
+ protected createActor(descriptor: RectAreaLightDescriptor, args: UpdateArgs) {
11
+ const actor = new NodeActor(new RectAreaLight())
12
+ return actor
13
+ }
14
+
15
+ setLight(actor: NodeActor<RectAreaLight>, descriptor: RectAreaLightDescriptor, args: UpdateArgs) {
16
+ actor.object.color.set(descriptor.color)
17
+ actor.object.intensity = descriptor.intensity
18
+ actor.object.width = descriptor.width
19
+ actor.object.height = descriptor.height
20
+ actor.object.power = descriptor.power
21
+ }
22
+
23
+ update(descriptor: RectAreaLightDescriptor, args: UpdateArgs) {
24
+ super.update(descriptor, args)
25
+ const actor = this.getActor<NodeActor<RectAreaLight>>(descriptor, args)
26
+ this.setLight(actor, descriptor, args)
27
+ }
28
+
29
+ pickup(descriptor: RectAreaLightDescriptor, args: UpdateArgs, result: PickupObject[]) { }
30
+ }
31
+ NodeInterpreter.register(RectAreaLightInterpreter)
32
+
33
+
34
+ export { RectAreaLightInterpreter }
@@ -0,0 +1,68 @@
1
+ import { Object3D, SpotLight } from "three";
2
+ import { Descriptor, PickupObject, UpdateArgs } from "@vyr/engine";
3
+ import { NodeInterpreter } from "../NodeInterpreter";
4
+ import { SpotLightDescriptor } from "../../descriptor";
5
+ import { NodeActor } from "../../actor";
6
+
7
+ class SpotLightInterpreter extends NodeInterpreter {
8
+ static type = SpotLightDescriptor.type
9
+
10
+ protected createActor(descriptor: SpotLightDescriptor, args: UpdateArgs) {
11
+ const actor = new NodeActor(new SpotLight())
12
+ return actor
13
+ }
14
+
15
+ setLight(actor: NodeActor<SpotLight>, descriptor: SpotLightDescriptor, args: UpdateArgs) {
16
+ actor.object.color.set(descriptor.color)
17
+ actor.object.intensity = descriptor.intensity
18
+ actor.object.angle = descriptor.angle
19
+ actor.object.decay = descriptor.decay
20
+ actor.object.distance = descriptor.distance
21
+ actor.object.penumbra = descriptor.penumbra
22
+ actor.object.power = descriptor.power
23
+ const mapSize = descriptor.mapSize
24
+ const camera = descriptor.camera
25
+ actor.object.shadow.mapSize.set(mapSize.x, mapSize.y)
26
+ actor.object.shadow.camera.near = camera.near
27
+ actor.object.shadow.camera.far = camera.far
28
+ }
29
+
30
+ setTarget(actor: NodeActor<SpotLight>, descriptor: SpotLightDescriptor, args: UpdateArgs) {
31
+ if (descriptor.target === '') {
32
+ const target = new Object3D()
33
+ target.position.copy(actor.object.target.position)
34
+ actor.object.target = target
35
+ } else {
36
+ const target = Descriptor.get<Descriptor>(descriptor.target)
37
+ if (target !== null) {
38
+ const targetActor = this.graphics.getActor<NodeActor>(target, args)
39
+ if (targetActor instanceof NodeActor) {
40
+ actor.object.target = targetActor.object
41
+ } else {
42
+ actor.object.target = new Object3D()
43
+ }
44
+ } else {
45
+ actor.object.target = new Object3D()
46
+ }
47
+ }
48
+ }
49
+
50
+ update(descriptor: SpotLightDescriptor, args: UpdateArgs) {
51
+ super.update(descriptor, args)
52
+ const actor = this.getActor<NodeActor<SpotLight>>(descriptor, args)
53
+ this.setLight(actor, descriptor, args)
54
+ this.setTarget(actor, descriptor, args)
55
+ }
56
+
57
+ free(descriptor: SpotLightDescriptor, args: UpdateArgs) {
58
+ const actor = this.getActor<NodeActor<SpotLight>>(descriptor, args)
59
+ actor.object.dispose()
60
+ super.free(descriptor, args)
61
+ }
62
+
63
+ pickup(descriptor: SpotLightDescriptor, args: UpdateArgs, result: PickupObject[]) { }
64
+ }
65
+ NodeInterpreter.register(SpotLightInterpreter)
66
+
67
+
68
+ export { SpotLightInterpreter }
@@ -0,0 +1,34 @@
1
+ import { Material } from "three";
2
+ import { Interpreter, UpdateArgs } from "@vyr/engine";
3
+ import { MaterialDescriptor } from "../../descriptor";
4
+ import { MaterialActor } from "../../actor";
5
+ import { material as _material } from "../../utils";
6
+
7
+ class MaterialInterpreter extends Interpreter {
8
+ static type = MaterialDescriptor.type
9
+
10
+ setProperty(material: Material, descriptor: MaterialDescriptor) {
11
+ material.alphaTest = descriptor.alphaTest
12
+ material.transparent = descriptor.transparent
13
+ material.colorWrite = descriptor.colorWrite
14
+ material.depthTest = descriptor.depthTest
15
+ material.depthWrite = descriptor.depthrWrite
16
+ //@ts-ignore
17
+ material.side = descriptor.side
18
+ //@ts-ignore
19
+ material.depthFunc = descriptor.depthFunc
20
+ //@ts-ignore
21
+ material.blending = descriptor.blending
22
+ material.vertexColors = descriptor.vertexColors
23
+ material.needsUpdate = true
24
+ }
25
+
26
+ free(descriptor: MaterialDescriptor, args: UpdateArgs) {
27
+ const actor = this.getActor<MaterialActor>(descriptor, args)
28
+ actor.object.dispose()
29
+ super.free(descriptor, args)
30
+ }
31
+ }
32
+ Interpreter.register(MaterialInterpreter)
33
+
34
+ export { MaterialInterpreter }
@@ -0,0 +1,43 @@
1
+ import { MeshBasicMaterial } from "three";
2
+ import { UpdateArgs } from "@vyr/engine";
3
+ import { MaterialInterpreter } from './MaterialInterpreter'
4
+ import { MeshBasicMaterialDescriptor } from "../../descriptor";
5
+ import { MaterialActor } from "../../actor";
6
+ import { texture } from "../../utils";
7
+
8
+ class MeshBasicMaterialInterpreter extends MaterialInterpreter {
9
+ static type = MeshBasicMaterialDescriptor.type
10
+
11
+ protected createActor(descriptor: MeshBasicMaterialDescriptor, args: UpdateArgs) {
12
+ const actor = new MaterialActor(new MeshBasicMaterial())
13
+ return actor
14
+ }
15
+
16
+ setProperty(material: MeshBasicMaterial, descriptor: MeshBasicMaterialDescriptor) {
17
+ super.setProperty(material, descriptor)
18
+
19
+ material.color.setStyle(descriptor.color.value)
20
+ material.opacity = descriptor.color.opacity
21
+ material.reflectivity = descriptor.reflectivity
22
+ material.refractionRatio = descriptor.refractionRatio
23
+ material.lightMapIntensity = descriptor.lightMapIntensity
24
+ //@ts-ignore
25
+ material.combine = descriptor.combine
26
+ material.fog = descriptor.fog
27
+ material.wireframe = descriptor.wireframe
28
+ }
29
+
30
+ update(descriptor: MeshBasicMaterialDescriptor, args: UpdateArgs) {
31
+ super.update(descriptor, args)
32
+ const actor = this.getActor<MaterialActor<MeshBasicMaterial>>(descriptor, args)
33
+ this.setProperty(actor.object, descriptor)
34
+ texture.setMap(actor.object, 'map', descriptor, this.graphics, args)
35
+ texture.setMap(actor.object, 'alphaMap', descriptor, this.graphics, args)
36
+ texture.setMap(actor.object, 'envMap', descriptor, this.graphics, args)
37
+ texture.setMap(actor.object, 'lightMap', descriptor, this.graphics, args)
38
+ texture.setMap(actor.object, 'specularMap', descriptor, this.graphics, args)
39
+ }
40
+ }
41
+ MaterialInterpreter.register(MeshBasicMaterialInterpreter)
42
+
43
+ export { MeshBasicMaterialInterpreter }
@@ -0,0 +1,63 @@
1
+ import { MeshPhongMaterial } from "three";
2
+ import { UpdateArgs } from "@vyr/engine";
3
+ import { MaterialInterpreter } from "./MaterialInterpreter";
4
+ import { MeshPhongMaterialDescriptor } from "../../descriptor";
5
+ import { MaterialActor } from "../../actor";
6
+ import { texture } from "../../utils";
7
+
8
+ class MeshPhongMaterialInterpreter extends MaterialInterpreter {
9
+ static type = MeshPhongMaterialDescriptor.type
10
+
11
+ protected createActor(descriptor: MeshPhongMaterialDescriptor, args: UpdateArgs) {
12
+ const actor = new MaterialActor(new MeshPhongMaterial())
13
+ return actor
14
+ }
15
+
16
+ setProperty(material: MeshPhongMaterial, descriptor: MeshPhongMaterialDescriptor) {
17
+ super.setProperty(material, descriptor)
18
+
19
+ material.color.setStyle(descriptor.color.value)
20
+ material.opacity = descriptor.color.opacity
21
+ material.emissive.setStyle(descriptor.emissive)
22
+ material.specular.setStyle(descriptor.specular)
23
+ material.reflectivity = descriptor.reflectivity
24
+ material.refractionRatio = descriptor.refractionRatio
25
+ material.lightMapIntensity = descriptor.lightMapIntensity
26
+ //@ts-ignore
27
+ material.combine = descriptor.combine
28
+
29
+ material.aoMapIntensity = descriptor.aoMapIntensity
30
+ material.bumpScale = descriptor.bumpScale
31
+ material.displacementScale = descriptor.displacementScale
32
+ material.displacementBias = descriptor.displacementBias
33
+ material.emissiveIntensity = descriptor.emissiveIntensity
34
+ material.envMapRotation.set(descriptor.envMapRotation.x, descriptor.envMapRotation.y, descriptor.envMapRotation.z)
35
+ material.lightMapIntensity = descriptor.lightMapIntensity
36
+ //@ts-ignore
37
+ material.normalMapType = descriptor.normalMapType
38
+ material.reflectivity = descriptor.reflectivity
39
+ material.refractionRatio = descriptor.refractionRatio
40
+ material.shininess = descriptor.shininess
41
+ material.flatShading = descriptor.flatShading
42
+ material.fog = descriptor.fog
43
+ material.wireframe = descriptor.wireframe
44
+ }
45
+
46
+ update(descriptor: MeshPhongMaterialDescriptor, args: UpdateArgs) {
47
+ super.update(descriptor, args)
48
+ const actor = this.getActor<MaterialActor<MeshPhongMaterial>>(descriptor, args)
49
+ this.setProperty(actor.object, descriptor)
50
+ texture.setMap(actor.object, 'map', descriptor, this.graphics, args)
51
+ texture.setMap(actor.object, 'alphaMap', descriptor, this.graphics, args)
52
+ texture.setMap(actor.object, 'envMap', descriptor, this.graphics, args)
53
+ texture.setMap(actor.object, 'lightMap', descriptor, this.graphics, args)
54
+ texture.setMap(actor.object, 'specularMap', descriptor, this.graphics, args)
55
+ texture.setMap(actor.object, 'aoMap', descriptor, this.graphics, args)
56
+ texture.setMap(actor.object, 'bumpMap', descriptor, this.graphics, args)
57
+ texture.setMap(actor.object, 'emissiveMap', descriptor, this.graphics, args)
58
+ texture.setMap(actor.object, 'normalMap', descriptor, this.graphics, args)
59
+ }
60
+ }
61
+ MaterialInterpreter.register(MeshPhongMaterialInterpreter)
62
+
63
+ export { MeshPhongMaterialInterpreter }