@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,30 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine"
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
/**圆柱 */
|
|
5
|
+
class CylinderGeometryDescriptor extends GeometryDescriptor {
|
|
6
|
+
static type = 'CylinderGeometry'
|
|
7
|
+
radiusTop: number
|
|
8
|
+
radiusBottom: number
|
|
9
|
+
height: number
|
|
10
|
+
radialSegments: number
|
|
11
|
+
heightSegments: number
|
|
12
|
+
openEnded: boolean
|
|
13
|
+
thetaStart: number
|
|
14
|
+
thetaLength: number
|
|
15
|
+
|
|
16
|
+
constructor(descriptor: Partial<DeserializationObject<CylinderGeometryDescriptor>> = {}) {
|
|
17
|
+
super(descriptor)
|
|
18
|
+
this.radiusTop = descriptor.radiusTop ?? 1
|
|
19
|
+
this.radiusBottom = descriptor.radiusBottom ?? 1
|
|
20
|
+
this.height = descriptor.height ?? 1
|
|
21
|
+
this.radialSegments = descriptor.radialSegments ?? 32
|
|
22
|
+
this.heightSegments = descriptor.heightSegments ?? 1
|
|
23
|
+
this.openEnded = descriptor.openEnded ?? false
|
|
24
|
+
this.thetaStart = descriptor.thetaStart ?? 0
|
|
25
|
+
this.thetaLength = descriptor.thetaLength ?? Math.PI * 2
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
GeometryDescriptor.register(CylinderGeometryDescriptor)
|
|
29
|
+
|
|
30
|
+
export { CylinderGeometryDescriptor }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DeserializationObject, Vector2 } from "@vyr/engine"
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
class ExtrudeGeometryDescriptor extends GeometryDescriptor {
|
|
5
|
+
static type = 'ExtrudeGeometry'
|
|
6
|
+
shapes: string
|
|
7
|
+
offset: Vector2
|
|
8
|
+
flattenUVsToPlane: boolean
|
|
9
|
+
curveSegments: number
|
|
10
|
+
steps: number
|
|
11
|
+
depth: number
|
|
12
|
+
bevelEnabled: boolean
|
|
13
|
+
bevelThickness: number
|
|
14
|
+
bevelSize: number
|
|
15
|
+
bevelOffset: number
|
|
16
|
+
bevelSegments: number
|
|
17
|
+
|
|
18
|
+
constructor(descriptor: Partial<DeserializationObject<ExtrudeGeometryDescriptor>> = {}) {
|
|
19
|
+
super(descriptor)
|
|
20
|
+
this.shapes = descriptor.shapes ?? ''
|
|
21
|
+
this.offset = descriptor.offset ? GeometryDescriptor.deepClone(descriptor.offset) : new Vector2()
|
|
22
|
+
this.flattenUVsToPlane = descriptor.flattenUVsToPlane ?? false
|
|
23
|
+
this.curveSegments = descriptor.curveSegments ?? 12
|
|
24
|
+
this.steps = descriptor.steps ?? 1
|
|
25
|
+
this.depth = descriptor.depth ?? 1
|
|
26
|
+
this.bevelEnabled = descriptor.bevelEnabled ?? true
|
|
27
|
+
this.bevelThickness = descriptor.bevelThickness ?? 0.2
|
|
28
|
+
this.bevelSize = descriptor.bevelSize ?? 0.1
|
|
29
|
+
this.bevelOffset = descriptor.bevelOffset ?? 0
|
|
30
|
+
this.bevelSegments = descriptor.bevelSegments ?? 3
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
GeometryDescriptor.register(ExtrudeGeometryDescriptor)
|
|
34
|
+
|
|
35
|
+
export { ExtrudeGeometryDescriptor }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine"
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
/**平面 */
|
|
5
|
+
class PlaneGeometryDescriptor extends GeometryDescriptor {
|
|
6
|
+
static type = 'PlaneGeometry'
|
|
7
|
+
width: number
|
|
8
|
+
height: number
|
|
9
|
+
widthSegments: number
|
|
10
|
+
heightSegments: number
|
|
11
|
+
|
|
12
|
+
constructor(descriptor: Partial<DeserializationObject<PlaneGeometryDescriptor>> = {}) {
|
|
13
|
+
super(descriptor)
|
|
14
|
+
this.width = descriptor.width ?? 1
|
|
15
|
+
this.height = descriptor.height ?? 1
|
|
16
|
+
this.widthSegments = descriptor.widthSegments ?? 1
|
|
17
|
+
this.heightSegments = descriptor.heightSegments ?? 1
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
GeometryDescriptor.register(PlaneGeometryDescriptor)
|
|
21
|
+
|
|
22
|
+
export { PlaneGeometryDescriptor }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine"
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
/**圆环 */
|
|
5
|
+
class RingGeometryDescriptor extends GeometryDescriptor {
|
|
6
|
+
static type = 'RingGeometry'
|
|
7
|
+
innerRadius: number
|
|
8
|
+
outerRadius: number
|
|
9
|
+
thetaSegments: number
|
|
10
|
+
phiSegments: number
|
|
11
|
+
thetaStart: number
|
|
12
|
+
thetaLength: number
|
|
13
|
+
|
|
14
|
+
constructor(descriptor: Partial<DeserializationObject<RingGeometryDescriptor>> = {}) {
|
|
15
|
+
super(descriptor)
|
|
16
|
+
this.innerRadius = descriptor.innerRadius ?? 0.5
|
|
17
|
+
this.outerRadius = descriptor.outerRadius ?? 1
|
|
18
|
+
this.thetaSegments = descriptor.thetaSegments ?? 32
|
|
19
|
+
this.phiSegments = descriptor.phiSegments ?? 1
|
|
20
|
+
this.thetaStart = descriptor.thetaStart ?? 0
|
|
21
|
+
this.thetaLength = descriptor.thetaLength ?? Math.PI * 2
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
GeometryDescriptor.register(RingGeometryDescriptor)
|
|
25
|
+
|
|
26
|
+
export { RingGeometryDescriptor }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine"
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
class SphereGeometryDescriptor extends GeometryDescriptor {
|
|
5
|
+
static type = 'SphereGeometry'
|
|
6
|
+
radius: number
|
|
7
|
+
widthSegments: number
|
|
8
|
+
heightSegments: number
|
|
9
|
+
phiStart: number
|
|
10
|
+
phiLength: number
|
|
11
|
+
thetaStart: number
|
|
12
|
+
thetaLength: number
|
|
13
|
+
|
|
14
|
+
constructor(descriptor: Partial<DeserializationObject<SphereGeometryDescriptor>> = {}) {
|
|
15
|
+
super(descriptor)
|
|
16
|
+
this.radius = descriptor.radius ?? 1
|
|
17
|
+
this.widthSegments = descriptor.widthSegments ?? 32
|
|
18
|
+
this.heightSegments = descriptor.heightSegments ?? 16
|
|
19
|
+
this.phiStart = descriptor.phiStart ?? 0
|
|
20
|
+
this.phiLength = descriptor.phiLength ?? Math.PI * 2
|
|
21
|
+
this.thetaStart = descriptor.thetaStart ?? 0
|
|
22
|
+
this.thetaLength = descriptor.thetaLength ?? Math.PI
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
GeometryDescriptor.register(SphereGeometryDescriptor)
|
|
26
|
+
|
|
27
|
+
export { SphereGeometryDescriptor }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine"
|
|
2
|
+
import { ExtrudeGeometryDescriptor } from "./ExtrudeGeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
class SurfaceGeometryDescriptor extends ExtrudeGeometryDescriptor {
|
|
5
|
+
static type = 'SurfaceGeometry'
|
|
6
|
+
radius: number
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<SurfaceGeometryDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.radius = descriptor.radius ?? 1
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
ExtrudeGeometryDescriptor.register(SurfaceGeometryDescriptor)
|
|
14
|
+
|
|
15
|
+
export { SurfaceGeometryDescriptor }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DeserializationObject, Vector2 } from "@vyr/engine"
|
|
2
|
+
import { GeometryDescriptor } from "./GeometryDescriptor"
|
|
3
|
+
|
|
4
|
+
class TubeGeometryDescriptor extends GeometryDescriptor {
|
|
5
|
+
static type = 'TubeGeometry'
|
|
6
|
+
track: string
|
|
7
|
+
offset: Vector2
|
|
8
|
+
tubularSegments: number
|
|
9
|
+
radius: number
|
|
10
|
+
radialSegments: number
|
|
11
|
+
closed: boolean
|
|
12
|
+
|
|
13
|
+
constructor(descriptor: Partial<DeserializationObject<TubeGeometryDescriptor>> = {}) {
|
|
14
|
+
super(descriptor)
|
|
15
|
+
this.track = descriptor.track ?? ''
|
|
16
|
+
this.offset = descriptor.offset ? GeometryDescriptor.deepClone(descriptor.offset) : new Vector2()
|
|
17
|
+
this.tubularSegments = descriptor.tubularSegments ?? 64
|
|
18
|
+
this.radius = descriptor.radius ?? 1
|
|
19
|
+
this.radialSegments = descriptor.radialSegments ?? 8
|
|
20
|
+
this.closed = descriptor.closed ?? false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
GeometryDescriptor.register(TubeGeometryDescriptor)
|
|
24
|
+
|
|
25
|
+
export { TubeGeometryDescriptor }
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export * from './geometry/GeometryDescriptor'
|
|
2
|
+
export * from './geometry/BoxGeometryDescriptor'
|
|
3
|
+
export * from './geometry/CircleGeometryDescriptor'
|
|
4
|
+
export * from './geometry/CylinderGeometryDescriptor'
|
|
5
|
+
export * from './geometry/PlaneGeometryDescriptor'
|
|
6
|
+
export * from './geometry/RingGeometryDescriptor'
|
|
7
|
+
export * from './geometry/SphereGeometryDescriptor'
|
|
8
|
+
export * from './geometry/ExtrudeGeometryDescriptor'
|
|
9
|
+
export * from './geometry/SurfaceGeometryDescriptor'
|
|
10
|
+
export * from './geometry/TubeGeometryDescriptor'
|
|
11
|
+
export * from './geometry/BufferGeometryDescriptor'
|
|
12
|
+
export * from './material/MaterialDescriptor'
|
|
13
|
+
export * from './material/MeshBasicMaterialDescriptor'
|
|
14
|
+
export * from './material/MeshPhongMaterialDescriptor'
|
|
15
|
+
export * from './material/MeshStandardMaterialDescriptor'
|
|
16
|
+
export * from './material/PointsMaterialDescriptor'
|
|
17
|
+
export * from './material/SpriteMaterialDescriptor'
|
|
18
|
+
export * from './material/ShadowMaterialDescriptor'
|
|
19
|
+
export * from './material/ShaderMaterialDescriptor'
|
|
20
|
+
export * from './texture/TextureDescriptor'
|
|
21
|
+
export * from './animation/AnimationActionDescriptor'
|
|
22
|
+
export * from './light/LightDescriptor'
|
|
23
|
+
export * from './light/AmbientLightDescriptor'
|
|
24
|
+
export * from './light/DirectionalLightDescriptor'
|
|
25
|
+
export * from './light/HemisphereLightDescriptor'
|
|
26
|
+
export * from './light/PointLightDescriptor'
|
|
27
|
+
export * from './light/RectAreaLightDescriptor'
|
|
28
|
+
export * from './light/SpotLightDescriptor'
|
|
29
|
+
export * from './MeshDescriptor'
|
|
30
|
+
export * from './InstancedMeshDescriptor'
|
|
31
|
+
export * from './TextDescriptor'
|
|
32
|
+
export * from './PointsDescriptor'
|
|
33
|
+
export * from './ParticleDescriptor'
|
|
34
|
+
export * from './SpriteDescriptor'
|
|
35
|
+
export * from './HTMLConvertDescriptor'
|
|
36
|
+
export * from './GeoMapDescriptor'
|
|
37
|
+
export * from './ModelDescriptor'
|
|
38
|
+
export * from './OrthographicCameraDescriptor'
|
|
39
|
+
export * from './PerspectiveCameraDescriptor'
|
|
40
|
+
export * from './OrbitControllerDescriptor'
|
|
41
|
+
export * from './TransformControllerDescriptor'
|
|
42
|
+
export * from './helper/AxesHelperDescriptor'
|
|
43
|
+
export * from './SceneServiceDescriptor'
|
|
44
|
+
// export * from './ComposerServiceDescriptor'
|
|
45
|
+
// export * from './PassDescriptor'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DeserializationObject, Vector2 } from "@vyr/engine";
|
|
2
|
+
import { LightDescriptor } from "./LightDescriptor";
|
|
3
|
+
|
|
4
|
+
interface DirectionalCamera {
|
|
5
|
+
near: number;
|
|
6
|
+
far: number
|
|
7
|
+
left: number
|
|
8
|
+
right: number
|
|
9
|
+
top: number
|
|
10
|
+
bottom: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class DirectionalLightDescriptor extends LightDescriptor {
|
|
14
|
+
static type = 'DirectionalLight'
|
|
15
|
+
|
|
16
|
+
target: string
|
|
17
|
+
bias: number
|
|
18
|
+
normalBias: number
|
|
19
|
+
mapSize: Vector2
|
|
20
|
+
camera: DirectionalCamera
|
|
21
|
+
|
|
22
|
+
constructor(descriptor: Partial<DeserializationObject<DirectionalLightDescriptor>> = {}) {
|
|
23
|
+
super(descriptor)
|
|
24
|
+
this.target = descriptor.target ?? ''
|
|
25
|
+
this.bias = descriptor.bias ?? 0
|
|
26
|
+
this.normalBias = descriptor.normalBias ?? 0
|
|
27
|
+
this.mapSize = descriptor.mapSize ? Vector2.create(descriptor.mapSize) : Vector2.create(512, 512)
|
|
28
|
+
this.camera = descriptor.camera ? LightDescriptor.deepClone(descriptor.camera) : { near: 0.5, far: 500, left: -5, right: 5, top: 5, bottom: -5 }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
LightDescriptor.register(DirectionalLightDescriptor)
|
|
32
|
+
|
|
33
|
+
export { DirectionalLightDescriptor }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine";
|
|
2
|
+
import { LightDescriptor } from "./LightDescriptor";
|
|
3
|
+
|
|
4
|
+
class HemisphereLightDescriptor extends LightDescriptor {
|
|
5
|
+
static type = 'HemisphereLight'
|
|
6
|
+
|
|
7
|
+
groundColor: string
|
|
8
|
+
|
|
9
|
+
constructor(descriptor: Partial<DeserializationObject<HemisphereLightDescriptor>> = {}) {
|
|
10
|
+
super(descriptor)
|
|
11
|
+
this.groundColor = descriptor.groundColor ?? '#ffffff'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
LightDescriptor.register(HemisphereLightDescriptor)
|
|
15
|
+
|
|
16
|
+
export { HemisphereLightDescriptor }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DeserializationObject, NodeDescriptor } from "@vyr/engine";
|
|
2
|
+
|
|
3
|
+
class LightDescriptor extends NodeDescriptor {
|
|
4
|
+
static type = 'Light'
|
|
5
|
+
color: string
|
|
6
|
+
intensity: number
|
|
7
|
+
|
|
8
|
+
constructor(descriptor: Partial<DeserializationObject<LightDescriptor>> = {}) {
|
|
9
|
+
super(descriptor)
|
|
10
|
+
this.color = descriptor.color ?? '#ffffff'
|
|
11
|
+
this.intensity = descriptor.intensity ?? 1
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
NodeDescriptor.register(LightDescriptor)
|
|
15
|
+
|
|
16
|
+
export { LightDescriptor }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DeserializationObject, Vector2 } from "@vyr/engine";
|
|
2
|
+
import { LightDescriptor } from "./LightDescriptor";
|
|
3
|
+
|
|
4
|
+
class PointLightDescriptor extends LightDescriptor {
|
|
5
|
+
static type = 'PointLight'
|
|
6
|
+
|
|
7
|
+
distance: number
|
|
8
|
+
decay: number
|
|
9
|
+
power: number
|
|
10
|
+
mapSize: Vector2
|
|
11
|
+
camera: { near: number; far: number }
|
|
12
|
+
|
|
13
|
+
constructor(descriptor: Partial<DeserializationObject<PointLightDescriptor>> = {}) {
|
|
14
|
+
super(descriptor)
|
|
15
|
+
this.distance = descriptor.distance ?? 0
|
|
16
|
+
this.decay = descriptor.decay ?? 2
|
|
17
|
+
this.power = descriptor.power ?? 1
|
|
18
|
+
this.mapSize = descriptor.mapSize ? Vector2.create(descriptor.mapSize) : Vector2.create(512, 512)
|
|
19
|
+
this.camera = descriptor.camera ? LightDescriptor.deepClone(descriptor.camera) : { near: 0.5, far: 500 }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
LightDescriptor.register(PointLightDescriptor)
|
|
23
|
+
|
|
24
|
+
export { PointLightDescriptor }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DeserializationObject } from "@vyr/engine";
|
|
2
|
+
import { LightDescriptor } from "./LightDescriptor";
|
|
3
|
+
|
|
4
|
+
class RectAreaLightDescriptor extends LightDescriptor {
|
|
5
|
+
static type = 'RectAreaLight'
|
|
6
|
+
|
|
7
|
+
width: number
|
|
8
|
+
height: number
|
|
9
|
+
power: number
|
|
10
|
+
|
|
11
|
+
constructor(descriptor: Partial<DeserializationObject<RectAreaLightDescriptor>> = {}) {
|
|
12
|
+
super(descriptor)
|
|
13
|
+
this.width = descriptor.width ?? 10
|
|
14
|
+
this.height = descriptor.height ?? 10
|
|
15
|
+
this.power = descriptor.power ?? 1
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
LightDescriptor.register(RectAreaLightDescriptor)
|
|
19
|
+
|
|
20
|
+
export { RectAreaLightDescriptor }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DeserializationObject, Vector2 } from "@vyr/engine";
|
|
2
|
+
import { LightDescriptor } from "./LightDescriptor";
|
|
3
|
+
|
|
4
|
+
class SpotLightDescriptor extends LightDescriptor {
|
|
5
|
+
static type = 'SpotLight'
|
|
6
|
+
|
|
7
|
+
angle: number
|
|
8
|
+
decay: number
|
|
9
|
+
distance: number
|
|
10
|
+
penumbra: number
|
|
11
|
+
power: number
|
|
12
|
+
target: string
|
|
13
|
+
mapSize: Vector2
|
|
14
|
+
camera: { near: number; far: number }
|
|
15
|
+
|
|
16
|
+
constructor(descriptor: Partial<DeserializationObject<SpotLightDescriptor>> = {}) {
|
|
17
|
+
super(descriptor)
|
|
18
|
+
this.angle = descriptor.angle ?? Math.PI / 3
|
|
19
|
+
this.decay = descriptor.decay ?? 2
|
|
20
|
+
this.distance = descriptor.distance ?? 0
|
|
21
|
+
this.penumbra = descriptor.penumbra ?? 0
|
|
22
|
+
this.power = descriptor.power ?? 1
|
|
23
|
+
this.target = descriptor.target ?? ''
|
|
24
|
+
this.mapSize = descriptor.mapSize ? Vector2.create(descriptor.mapSize) : Vector2.create(512, 512)
|
|
25
|
+
this.camera = descriptor.camera ? LightDescriptor.deepClone(descriptor.camera) : { near: 0.5, far: 500 }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
LightDescriptor.register(SpotLightDescriptor)
|
|
29
|
+
|
|
30
|
+
export { SpotLightDescriptor }
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import { Descriptor, DeserializationObject } from '@vyr/engine'
|
|
3
|
+
|
|
4
|
+
enum MaterialSide {
|
|
5
|
+
FrontSide = THREE.FrontSide,
|
|
6
|
+
BackSide = THREE.BackSide,
|
|
7
|
+
DoubleSide = THREE.DoubleSide,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
enum MaterialDepthFunc {
|
|
11
|
+
NeverDepth = THREE.NeverDepth,
|
|
12
|
+
AlwaysDepth = THREE.AlwaysDepth,
|
|
13
|
+
LessDepth = THREE.LessDepth,
|
|
14
|
+
LessEqualDepth = THREE.LessEqualDepth,
|
|
15
|
+
GreaterEqualDepth = THREE.GreaterEqualDepth,
|
|
16
|
+
GreaterDepth = THREE.GreaterDepth,
|
|
17
|
+
NotEqualDepth = THREE.NotEqualDepth,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum MaterialDlending {
|
|
21
|
+
NoBlending = THREE.NoBlending,
|
|
22
|
+
NormalBlending = THREE.NormalBlending,
|
|
23
|
+
AdditiveBlending = THREE.AdditiveBlending,
|
|
24
|
+
SubtractiveBlending = THREE.SubtractiveBlending,
|
|
25
|
+
MultiplyBlending = THREE.MultiplyBlending,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
enum MaterialCombine {
|
|
29
|
+
MultiplyOperation = THREE.MultiplyOperation,
|
|
30
|
+
MixOperation = THREE.MixOperation,
|
|
31
|
+
AddOperation = THREE.AddOperation,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
enum MaterialNormalMapType {
|
|
35
|
+
TangentSpaceNormalMap = THREE.TangentSpaceNormalMap,
|
|
36
|
+
ObjectSpaceNormalMap = THREE.ObjectSpaceNormalMap,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class MaterialDescriptor extends Descriptor {
|
|
40
|
+
static type = 'Material'
|
|
41
|
+
|
|
42
|
+
/**透明度测试 */
|
|
43
|
+
alphaTest: number
|
|
44
|
+
/**材质是否透明 */
|
|
45
|
+
transparent: boolean
|
|
46
|
+
/**材质类型 */
|
|
47
|
+
side: MaterialSide
|
|
48
|
+
/**是否渲染材质的颜色 */
|
|
49
|
+
colorWrite: boolean
|
|
50
|
+
/**是否启用深度测试 */
|
|
51
|
+
depthTest: boolean
|
|
52
|
+
/**是否写入深度 */
|
|
53
|
+
depthrWrite: boolean
|
|
54
|
+
/**深度函数*/
|
|
55
|
+
depthFunc: MaterialDepthFunc
|
|
56
|
+
/** 混合函数,混合效果见 https://threejs.org/examples/#webgl_materials_blending */
|
|
57
|
+
blending: MaterialDlending
|
|
58
|
+
/**是否使用顶点着色 */
|
|
59
|
+
vertexColors: boolean
|
|
60
|
+
|
|
61
|
+
constructor(descriptor: Partial<DeserializationObject<MaterialDescriptor>> = {}) {
|
|
62
|
+
super(descriptor)
|
|
63
|
+
this.alphaTest = descriptor.alphaTest ?? 0
|
|
64
|
+
this.transparent = descriptor.transparent ?? false
|
|
65
|
+
this.side = descriptor.side ?? MaterialSide.FrontSide
|
|
66
|
+
this.colorWrite = descriptor.colorWrite ?? true
|
|
67
|
+
this.depthTest = descriptor.depthTest ?? true
|
|
68
|
+
this.depthrWrite = descriptor.depthrWrite ?? true
|
|
69
|
+
this.depthFunc = descriptor.depthFunc ?? MaterialDepthFunc.LessEqualDepth
|
|
70
|
+
this.blending = descriptor.blending ?? MaterialDlending.NormalBlending
|
|
71
|
+
this.vertexColors = descriptor.vertexColors ?? false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Descriptor.register(MaterialDescriptor)
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
MaterialSide,
|
|
79
|
+
MaterialDepthFunc,
|
|
80
|
+
MaterialDlending,
|
|
81
|
+
MaterialCombine,
|
|
82
|
+
MaterialNormalMapType,
|
|
83
|
+
MaterialDescriptor,
|
|
84
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DefaultStyleColor, DeserializationObject } from "@vyr/engine"
|
|
2
|
+
import { MaterialCombine, MaterialDescriptor } from "./MaterialDescriptor"
|
|
3
|
+
|
|
4
|
+
class MeshBasicMaterialDescriptor extends MaterialDescriptor {
|
|
5
|
+
static type = 'MeshBasicMaterial'
|
|
6
|
+
/**漫反射颜色 */
|
|
7
|
+
color: DefaultStyleColor
|
|
8
|
+
/**漫反射贴图 */
|
|
9
|
+
map: string
|
|
10
|
+
/**透明度贴图 */
|
|
11
|
+
alphaMap: string
|
|
12
|
+
/**表面颜色与环境贴图如何结合
|
|
13
|
+
* - 1 它将环境贴图和物体表面颜色进行相乘
|
|
14
|
+
* - 2 使用反射率来混和两种颜色
|
|
15
|
+
* - 3 用于对两种颜色进行相加
|
|
16
|
+
*/
|
|
17
|
+
combine: MaterialCombine
|
|
18
|
+
/**环境贴图对表面的影响程度 */
|
|
19
|
+
reflectivity: number
|
|
20
|
+
/**空气折射率 */
|
|
21
|
+
refractionRatio: number
|
|
22
|
+
/**烘焙光的强度 */
|
|
23
|
+
lightMapIntensity: number
|
|
24
|
+
/**环境贴图 */
|
|
25
|
+
envMap: string
|
|
26
|
+
/**光照贴图 */
|
|
27
|
+
lightMap: string
|
|
28
|
+
/**高光贴图 */
|
|
29
|
+
specularMap: string
|
|
30
|
+
/**材质是否受雾影响。默认为true。 */
|
|
31
|
+
fog: boolean
|
|
32
|
+
/**将几何体渲染为线框。默认值为false */
|
|
33
|
+
wireframe: boolean
|
|
34
|
+
|
|
35
|
+
constructor(descriptor: Partial<DeserializationObject<MeshBasicMaterialDescriptor>> = {}) {
|
|
36
|
+
super(descriptor)
|
|
37
|
+
this.color = descriptor.color ? new DefaultStyleColor(descriptor.color) : new DefaultStyleColor({ value: '#ffffff' })
|
|
38
|
+
this.map = descriptor.map ?? ''
|
|
39
|
+
this.alphaMap = descriptor.alphaMap ?? ''
|
|
40
|
+
this.combine = descriptor.combine ?? MaterialCombine.MultiplyOperation
|
|
41
|
+
this.reflectivity = descriptor.reflectivity ?? 1
|
|
42
|
+
this.refractionRatio = descriptor.refractionRatio ?? 0.98
|
|
43
|
+
this.lightMapIntensity = descriptor.lightMapIntensity ?? 1
|
|
44
|
+
this.envMap = descriptor.envMap ?? ''
|
|
45
|
+
this.lightMap = descriptor.lightMap ?? ''
|
|
46
|
+
this.specularMap = descriptor.specularMap ?? ''
|
|
47
|
+
this.fog = descriptor.fog ?? true
|
|
48
|
+
this.wireframe = descriptor.wireframe ?? false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
MaterialDescriptor.register(MeshBasicMaterialDescriptor)
|
|
52
|
+
|
|
53
|
+
export { MeshBasicMaterialDescriptor }
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { DefaultStyleColor, DeserializationObject, Euler, Vector2 } from "@vyr/engine"
|
|
2
|
+
import { MaterialCombine, MaterialDescriptor, MaterialNormalMapType } from "./MaterialDescriptor"
|
|
3
|
+
|
|
4
|
+
class MeshPhongMaterialDescriptor extends MaterialDescriptor {
|
|
5
|
+
static type = 'MeshPhongMaterial'
|
|
6
|
+
/**材质的颜色(Color),默认值为白色 (0xffffff)。 */
|
|
7
|
+
color: DefaultStyleColor
|
|
8
|
+
/**颜色贴图。可以选择包括一个alpha通道,通常与.transparent 或.alphaTest。默认为null。 纹理贴图颜色由漫反射颜色.color调节。 */
|
|
9
|
+
map: string
|
|
10
|
+
/**alpha贴图是一张灰度纹理,用于控制整个表面的不透明度。(黑色:完全透明;白色:完全不透明)。 默认值为null。 */
|
|
11
|
+
alphaMap: string
|
|
12
|
+
/**如何将表面颜色的结果与环境贴图(如果有)结合起来。 */
|
|
13
|
+
combine: MaterialCombine
|
|
14
|
+
/**环境贴图对表面的影响程度。默认值为1,有效范围介于0(无反射)和1(完全反射)之间。 */
|
|
15
|
+
reflectivity: number
|
|
16
|
+
/**空气的折射率(IOR)(约为1)除以材质的折射率。 */
|
|
17
|
+
refractionRatio: number
|
|
18
|
+
/**环境贴图。默认值为null。 */
|
|
19
|
+
envMap: string
|
|
20
|
+
/**光照贴图。默认值为null。lightMap需要第二组UV。 */
|
|
21
|
+
lightMap: string
|
|
22
|
+
/**烘焙光的强度。默认值为1。 */
|
|
23
|
+
lightMapIntensity: number
|
|
24
|
+
/**镜面反射贴图值会影响镜面高光以及环境贴图对表面的影响程度。 */
|
|
25
|
+
specularMap: string
|
|
26
|
+
|
|
27
|
+
/**环境贴图的旋转(以弧度为单位)。默认值为 (0,0,0)。 */
|
|
28
|
+
envMapRotation: Euler
|
|
29
|
+
/**该纹理的红色通道用作环境遮挡贴图。默认值为null。aoMap需要第二组UV。 */
|
|
30
|
+
aoMap: string
|
|
31
|
+
/**环境遮挡效果的强度。默认值为1。零是不遮挡效果。 */
|
|
32
|
+
aoMapIntensity: number
|
|
33
|
+
/**用于创建凹凸贴图的纹理。黑色和白色值映射到与光照相关的感知深度。凹凸实际上不会影响对象的几何形状,只影响光照。如果定义了法线贴图,则将忽略该贴图。 */
|
|
34
|
+
bumpMap: string
|
|
35
|
+
/**凹凸贴图会对材质产生多大影响。典型范围是0-1。默认值为1。 */
|
|
36
|
+
bumpScale: number
|
|
37
|
+
/**位移贴图会影响网格顶点的位置,与仅影响材质的光照和阴影的其他贴图不同,移位的顶点可以投射阴影,阻挡其他对象, 以及充当真实的几何体。位移纹理是指:网格的所有顶点被映射为图像中每个像素的值(白色是最高的),并且被重定位。 */
|
|
38
|
+
displacementMap: string
|
|
39
|
+
/**位移贴图对网格的影响程度(黑色是无位移,白色是最大位移)。如果没有设置位移贴图,则不会应用此值。默认值为1。 */
|
|
40
|
+
displacementScale: number
|
|
41
|
+
/**位移贴图在网格顶点上的偏移量。如果没有设置位移贴图,则不会应用此值。默认值为0。 */
|
|
42
|
+
displacementBias: number
|
|
43
|
+
/**材质的放射(光)颜色,基本上是不受其他光照影响的固有颜色。默认为黑色。 */
|
|
44
|
+
emissive: string
|
|
45
|
+
/**设置放射(发光)贴图。默认值为null。放射贴图颜色由放射颜色和强度所调节。 如果你有一个放射贴图,请务必将放射颜色设置为黑色以外的其他颜色。 */
|
|
46
|
+
emissiveMap: string
|
|
47
|
+
/**放射光强度。调节发光颜色。默认为1。 */
|
|
48
|
+
emissiveIntensity: number
|
|
49
|
+
/**用于创建法线贴图的纹理。RGB 值会影响每个像素片段的曲面法线,并更改颜色照亮的方式。法线贴图不会改变曲面的实际形状,只会改变光照。 如果材质的法线贴图使用左手惯例编写,则应将 normalScale 的 y 分量取反以补偿不同的手性。 */
|
|
50
|
+
normalMap: string
|
|
51
|
+
/**法线贴图的类型。*/
|
|
52
|
+
normalMapType: MaterialNormalMapType
|
|
53
|
+
/**法线贴图对材质的影响程度。典型范围是0-1。 */
|
|
54
|
+
normalScale: Vector2
|
|
55
|
+
/**specular高亮的程度,越高的值越闪亮。默认值为 30 */
|
|
56
|
+
shininess: number
|
|
57
|
+
/**材质的高光颜色。默认值为0x111111(深灰色)的颜色Color */
|
|
58
|
+
specular: string
|
|
59
|
+
/**定义材质是否使用平面着色进行渲染。默认值为false。 */
|
|
60
|
+
flatShading: boolean
|
|
61
|
+
|
|
62
|
+
/**材质是否受雾影响。默认为true。 */
|
|
63
|
+
fog: boolean
|
|
64
|
+
/**将几何体渲染为线框。默认值为false */
|
|
65
|
+
wireframe: boolean
|
|
66
|
+
|
|
67
|
+
constructor(descriptor: Partial<DeserializationObject<MeshPhongMaterialDescriptor>> = {}) {
|
|
68
|
+
super(descriptor)
|
|
69
|
+
this.alphaMap = descriptor.alphaMap ?? ''
|
|
70
|
+
this.aoMap = descriptor.aoMap ?? ''
|
|
71
|
+
this.aoMapIntensity = descriptor.aoMapIntensity ?? 1
|
|
72
|
+
this.bumpMap = descriptor.bumpMap ?? ''
|
|
73
|
+
this.bumpScale = descriptor.bumpScale ?? 1
|
|
74
|
+
this.color = descriptor.color ? new DefaultStyleColor(descriptor.color) : new DefaultStyleColor({ value: '#ffffff' })
|
|
75
|
+
this.combine = descriptor.combine ?? MaterialCombine.MultiplyOperation
|
|
76
|
+
this.displacementMap = descriptor.displacementMap ?? ''
|
|
77
|
+
this.displacementScale = descriptor.displacementScale ?? 1
|
|
78
|
+
this.displacementBias = descriptor.displacementBias ?? 0
|
|
79
|
+
this.emissive = descriptor.emissive ?? '#000000'
|
|
80
|
+
this.emissiveMap = descriptor.emissiveMap ?? ''
|
|
81
|
+
this.emissiveIntensity = descriptor.emissiveIntensity ?? 1
|
|
82
|
+
this.envMap = descriptor.envMap ?? ''
|
|
83
|
+
this.envMapRotation = Euler.create(descriptor.envMapRotation)
|
|
84
|
+
this.flatShading = descriptor.flatShading ?? false
|
|
85
|
+
this.lightMap = descriptor.lightMap ?? ''
|
|
86
|
+
this.lightMapIntensity = descriptor.lightMapIntensity ?? 1
|
|
87
|
+
this.map = descriptor.map ?? ''
|
|
88
|
+
this.normalMap = descriptor.normalMap ?? ''
|
|
89
|
+
this.normalMapType = descriptor.normalMapType ?? MaterialNormalMapType.TangentSpaceNormalMap
|
|
90
|
+
this.normalScale = descriptor.normalScale ? Vector2.create(descriptor.normalScale) : Vector2.create(1, 1)
|
|
91
|
+
this.reflectivity = descriptor.reflectivity ?? 1
|
|
92
|
+
this.refractionRatio = descriptor.refractionRatio ?? 0.98
|
|
93
|
+
this.shininess = descriptor.shininess ?? 30
|
|
94
|
+
this.specular = descriptor.specular ?? '#111111'
|
|
95
|
+
this.specularMap = descriptor.specularMap ?? ''
|
|
96
|
+
this.fog = descriptor.fog ?? true
|
|
97
|
+
this.wireframe = descriptor.wireframe ?? false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
MaterialDescriptor.register(MeshPhongMaterialDescriptor)
|
|
101
|
+
|
|
102
|
+
export { MeshPhongMaterialDescriptor }
|