lecodes-cli 0.19.0 → 0.20.0
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/README.md +1 -0
- package/dist/index.js +1069 -396
- package/package.json +14 -13
- package/runtime/scene-harness.json +1 -1
- package/runtime/sdk-types.json +1 -1
- package/runtime/web/assets/Roboto-Variable-DHm9jpd-.woff2 +0 -0
- package/runtime/web/assets/__vite-browser-external-BIHI7g3E.js +1 -0
- package/runtime/web/assets/basis-C64VHDVD.js +1 -0
- package/runtime/web/assets/basis_transcoder-VXdx5NbI.wasm +0 -0
- package/runtime/web/assets/createViewerLite-BvHobVhp.js +852 -0
- package/runtime/web/assets/draco-BiISTFcR.js +118 -0
- package/runtime/web/assets/draco_decoder-DsQ12WqX.wasm +0 -0
- package/runtime/web/assets/index-CfNCCBjN.js +2 -0
- package/runtime/web/assets/mapViewImpl-B2JcES8l.js +810 -0
- package/runtime/web/assets/maplibre-gl-worker-CJfwIrte.js +8 -0
- package/runtime/web/assets/neutral_ibl128-D-lzdkLN.ktx +0 -0
- package/runtime/web/assets/worker-Caf-yYEI.js +2 -0
- package/runtime/web/embed.html +32 -0
- package/runtime/web/embed.js +171 -0
- package/src/api.ts +302 -0
- package/src/browserAuth.ts +87 -0
- package/src/cmgenTool.ts +104 -0
- package/src/commands/app.ts +896 -0
- package/src/commands/appAndroid.ts +603 -0
- package/src/commands/appDesktop.ts +339 -0
- package/src/commands/appDesktopMac.ts +470 -0
- package/src/commands/appIcon.ts +187 -0
- package/src/commands/appShared.ts +542 -0
- package/src/commands/appTemplates.ts +907 -0
- package/src/commands/appTemplatesAndroid.ts +599 -0
- package/src/commands/appTemplatesGradlew.ts +9 -0
- package/src/commands/assets.ts +28 -0
- package/src/commands/clone.ts +60 -0
- package/src/commands/compile.ts +253 -0
- package/src/commands/create.ts +59 -0
- package/src/commands/design.ts +863 -0
- package/src/commands/designTemplates.ts +11 -0
- package/src/commands/desktop.ts +127 -0
- package/src/commands/dev.ts +236 -0
- package/src/commands/diff.ts +59 -0
- package/src/commands/init.ts +191 -0
- package/src/commands/install.ts +198 -0
- package/src/commands/lightmap.ts +290 -0
- package/src/commands/link.ts +147 -0
- package/src/commands/login.ts +24 -0
- package/src/commands/navmesh.ts +225 -0
- package/src/commands/pn.ts +305 -0
- package/src/commands/projectTemplates.ts +130 -0
- package/src/commands/pull.ts +109 -0
- package/src/commands/push.ts +173 -0
- package/src/commands/render.ts +416 -0
- package/src/commands/scene.ts +148 -0
- package/src/commands/shaders.ts +157 -0
- package/src/commands/status.ts +29 -0
- package/src/commands/test.ts +371 -0
- package/src/commands/thumbs.ts +178 -0
- package/src/commands/types.ts +87 -0
- package/src/commands/update.ts +190 -0
- package/src/compile/assetIcons.ts +214 -0
- package/src/compile/collect.ts +46 -0
- package/src/compile/collectLocal.ts +37 -0
- package/src/compile/designCompile.ts +104 -0
- package/src/compile/fonts.ts +156 -0
- package/src/compile/headlessBundle.ts +129 -0
- package/src/compile/nativeStack.ts +21 -0
- package/src/compile/projectCompile.ts +109 -0
- package/src/compile/sceneCompile.ts +113 -0
- package/src/compile/screenEntry.ts +127 -0
- package/src/compile/shaders.ts +245 -0
- package/src/config.ts +42 -0
- package/src/designMeta.ts +35 -0
- package/src/desktopRenderer.ts +545 -0
- package/src/desktopScript.ts +276 -0
- package/src/dev/clientTemplates.ts +160 -0
- package/src/dev/devServer.ts +333 -0
- package/src/dev/webRunner.ts +22 -0
- package/src/dev/wsServer.ts +144 -0
- package/src/distRoot.ts +20 -0
- package/src/ignore.ts +163 -0
- package/src/index.ts +494 -0
- package/src/lecodes-3d-editor.d.ts +41 -0
- package/src/lecodes-assets.d.ts +7 -0
- package/src/lecodes-design.d.ts +191 -0
- package/src/lecodes-renderer.d.ts +131 -0
- package/src/localFiles.ts +144 -0
- package/src/manifest.ts +46 -0
- package/src/matcTool.ts +137 -0
- package/src/peers.ts +40 -0
- package/src/project.ts +61 -0
- package/src/projectEnv.ts +94 -0
- package/src/qrcode-terminal.d.ts +9 -0
- package/src/releases.ts +125 -0
- package/src/serverDiff.ts +78 -0
- package/src/textDiff.ts +103 -0
- package/src/types.ts +0 -0
- package/src/util.ts +146 -0
- package/runtime/sdk/animate/animate.ts +0 -238
- package/runtime/sdk/animate/bezier.ts +0 -138
- package/runtime/sdk/animate/easings.ts +0 -126
- package/runtime/sdk/canvas/Canvas.ts +0 -305
- package/runtime/sdk/compile/aspectMacro.ts +0 -86
- package/runtime/sdk/compile/assetIconMacro.ts +0 -384
- package/runtime/sdk/compile/assetMacro.ts +0 -146
- package/runtime/sdk/compile/assetName.ts +0 -50
- package/runtime/sdk/compile/bundler.ts +0 -287
- package/runtime/sdk/compile/compileProject.ts +0 -129
- package/runtime/sdk/compile/detectEntry.ts +0 -128
- package/runtime/sdk/compile/fontMacro.ts +0 -459
- package/runtime/sdk/compile/fontRegistry.ts +0 -78
- package/runtime/sdk/compile/header.ts +0 -67
- package/runtime/sdk/compile/index.ts +0 -100
- package/runtime/sdk/compile/libraryImports.ts +0 -52
- package/runtime/sdk/compile/liteMaterial.ts +0 -247
- package/runtime/sdk/compile/sceneEditor.ts +0 -88
- package/runtime/sdk/compile/serverSplit.ts +0 -233
- package/runtime/sdk/compile/serverTypes.ts +0 -227
- package/runtime/sdk/compile/sfnt.ts +0 -98
- package/runtime/sdk/compile/shaderSchema.ts +0 -202
- package/runtime/sdk/compile/shaderTargets.ts +0 -81
- package/runtime/sdk/compile/sourcemap.ts +0 -25
- package/runtime/sdk/core/Aspect.ts +0 -568
- package/runtime/sdk/core/InspectorUI.ts +0 -212
- package/runtime/sdk/core/StateMachine.ts +0 -308
- package/runtime/sdk/core/color.ts +0 -66
- package/runtime/sdk/core/compWrite.ts +0 -42
- package/runtime/sdk/core/events.ts +0 -38
- package/runtime/sdk/core/fields.ts +0 -120
- package/runtime/sdk/core/registry.ts +0 -23
- package/runtime/sdk/core/signals.ts +0 -277
- package/runtime/sdk/core/time.ts +0 -84
- package/runtime/sdk/g2/Camera2D.ts +0 -40
- package/runtime/sdk/g2/CharacterController2D.ts +0 -276
- package/runtime/sdk/g2/Node2D.ts +0 -267
- package/runtime/sdk/g2/OneWay2D.ts +0 -66
- package/runtime/sdk/g2/Physics2D.ts +0 -346
- package/runtime/sdk/g2/Scene2D.ts +0 -209
- package/runtime/sdk/g2/Shape2D.ts +0 -259
- package/runtime/sdk/g2/Sprite.ts +0 -89
- package/runtime/sdk/g2/SpriteAnimation.ts +0 -171
- package/runtime/sdk/g2/SpriteSheet.ts +0 -166
- package/runtime/sdk/g2/Texture2D.ts +0 -47
- package/runtime/sdk/g2/Tilemap.ts +0 -41
- package/runtime/sdk/g2/Tileset.ts +0 -71
- package/runtime/sdk/g2/Trigger2D.ts +0 -77
- package/runtime/sdk/g2/autotile.ts +0 -433
- package/runtime/sdk/g2/cells.ts +0 -91
- package/runtime/sdk/g2/defineScene2d.ts +0 -381
- package/runtime/sdk/g2/groups2d.ts +0 -106
- package/runtime/sdk/g2/loop.ts +0 -50
- package/runtime/sdk/g2/scenarios2d.ts +0 -69
- package/runtime/sdk/g2/touch.ts +0 -83
- package/runtime/sdk/gl/Camera.ts +0 -160
- package/runtime/sdk/gl/CameraPlace.ts +0 -52
- package/runtime/sdk/gl/CharacterController.ts +0 -238
- package/runtime/sdk/gl/Gearbox.ts +0 -212
- package/runtime/sdk/gl/Geometry.ts +0 -279
- package/runtime/sdk/gl/IK.ts +0 -193
- package/runtime/sdk/gl/InstancedMesh.ts +0 -132
- package/runtime/sdk/gl/Light.ts +0 -107
- package/runtime/sdk/gl/Lightmap.ts +0 -256
- package/runtime/sdk/gl/Material.ts +0 -260
- package/runtime/sdk/gl/Mesh.ts +0 -83
- package/runtime/sdk/gl/Model.ts +0 -124
- package/runtime/sdk/gl/NavAgent.ts +0 -337
- package/runtime/sdk/gl/NavMesh.ts +0 -397
- package/runtime/sdk/gl/Node.ts +0 -350
- package/runtime/sdk/gl/Noise.ts +0 -30
- package/runtime/sdk/gl/Particles.ts +0 -676
- package/runtime/sdk/gl/Physics.ts +0 -222
- package/runtime/sdk/gl/Plane.ts +0 -53
- package/runtime/sdk/gl/Ragdoll.ts +0 -270
- package/runtime/sdk/gl/Ray.ts +0 -16
- package/runtime/sdk/gl/Scene.ts +0 -486
- package/runtime/sdk/gl/Shape.ts +0 -409
- package/runtime/sdk/gl/Terrain.ts +0 -1092
- package/runtime/sdk/gl/Texture.ts +0 -63
- package/runtime/sdk/gl/Trigger.ts +0 -45
- package/runtime/sdk/gl/Vehicle.ts +0 -473
- package/runtime/sdk/gl/Wheel.ts +0 -240
- package/runtime/sdk/gl/animation/AnimationClip.ts +0 -204
- package/runtime/sdk/gl/animation/Animator.ts +0 -120
- package/runtime/sdk/gl/animation/Layer.ts +0 -31
- package/runtime/sdk/gl/animation/Loop.ts +0 -30
- package/runtime/sdk/gl/animation/Playback.ts +0 -44
- package/runtime/sdk/gl/animation/core.ts +0 -336
- package/runtime/sdk/gl/controls.ts +0 -95
- package/runtime/sdk/gl/physicsEvents.ts +0 -20
- package/runtime/sdk/gl/scenarios.ts +0 -291
- package/runtime/sdk/gl/state.ts +0 -6
- package/runtime/sdk/gl/terrainMesh.ts +0 -219
- package/runtime/sdk/gl/touch.ts +0 -68
- package/runtime/sdk/inject.ts +0 -197
- package/runtime/sdk/math/Mathf.ts +0 -118
- package/runtime/sdk/math/mat4.ts +0 -278
- package/runtime/sdk/math/quat.ts +0 -232
- package/runtime/sdk/math/vec.ts +0 -255
- package/runtime/sdk/net/codec.ts +0 -119
- package/runtime/sdk/net/core.ts +0 -384
- package/runtime/sdk/net/index.ts +0 -181
- package/runtime/sdk/net/replication.ts +0 -622
- package/runtime/sdk/plugins/camera.ts +0 -81
- package/runtime/sdk/plugins/geolocation.ts +0 -123
- package/runtime/sdk/plugins/oauth.ts +0 -61
- package/runtime/sdk/plugins/permission.ts +0 -7
- package/runtime/sdk/plugins/push.ts +0 -132
- package/runtime/sdk/plugins/qr.ts +0 -73
- package/runtime/sdk/plugins/service.ts +0 -47
- package/runtime/sdk/runtime/app.ts +0 -101
- package/runtime/sdk/runtime/appEvents.ts +0 -54
- package/runtime/sdk/runtime/channel.ts +0 -61
- package/runtime/sdk/runtime/clipboard.ts +0 -20
- package/runtime/sdk/runtime/datetime.ts +0 -329
- package/runtime/sdk/runtime/device.ts +0 -293
- package/runtime/sdk/runtime/fetch.ts +0 -77
- package/runtime/sdk/runtime/files.ts +0 -23
- package/runtime/sdk/runtime/input.ts +0 -175
- package/runtime/sdk/runtime/media.ts +0 -111
- package/runtime/sdk/runtime/misc.ts +0 -16
- package/runtime/sdk/runtime/net.ts +0 -36
- package/runtime/sdk/runtime/rpc.ts +0 -218
- package/runtime/sdk/runtime/service.ts +0 -83
- package/runtime/sdk/runtime/share.ts +0 -9
- package/runtime/sdk/runtime/storage.ts +0 -13
- package/runtime/sdk/runtime/touch.ts +0 -76
- package/runtime/sdk/scene/defineScene.ts +0 -1353
- package/runtime/sdk/scene/editorPlugins.ts +0 -110
- package/runtime/sdk/scene/gizmos.ts +0 -148
- package/runtime/sdk/scene/grammar.ts +0 -120
- package/runtime/sdk/scene/material.ts +0 -188
- package/runtime/sdk/server/auth/appConfig.ts +0 -12
- package/runtime/sdk/server/auth/global.ts +0 -80
- package/runtime/sdk/server/auth/host.ts +0 -318
- package/runtime/sdk/server/auth/models.ts +0 -83
- package/runtime/sdk/server/auth/types.ts +0 -50
- package/runtime/sdk/server/channel.ts +0 -56
- package/runtime/sdk/server/context.ts +0 -36
- package/runtime/sdk/server/db/defineDb.ts +0 -237
- package/runtime/sdk/server/db/fields.ts +0 -132
- package/runtime/sdk/server/db/httpTransport.ts +0 -93
- package/runtime/sdk/server/db/index.ts +0 -7
- package/runtime/sdk/server/db/marci/query.ts +0 -412
- package/runtime/sdk/server/db/types.ts +0 -202
- package/runtime/sdk/server/errors.ts +0 -12
- package/runtime/sdk/server/host.ts +0 -74
- package/runtime/sdk/server/inject.ts +0 -13
- package/runtime/sdk/server/runtime.ts +0 -133
- package/runtime/sdk/server/validate.ts +0 -87
- package/runtime/sdk/ui/NativeView.ts +0 -142
- package/runtime/sdk/ui/UI.ts +0 -39
- package/runtime/sdk/ui/UIBottomSheet.ts +0 -139
- package/runtime/sdk/ui/UIButton.ts +0 -101
- package/runtime/sdk/ui/UIContainer.ts +0 -60
- package/runtime/sdk/ui/UIImage.ts +0 -83
- package/runtime/sdk/ui/UIInput.ts +0 -185
- package/runtime/sdk/ui/UIModal.ts +0 -139
- package/runtime/sdk/ui/UINode.ts +0 -830
- package/runtime/sdk/ui/UIPager.ts +0 -362
- package/runtime/sdk/ui/UIPopover.ts +0 -100
- package/runtime/sdk/ui/UIScreen.ts +0 -123
- package/runtime/sdk/ui/UIScrollable.ts +0 -87
- package/runtime/sdk/ui/UISpacer.ts +0 -14
- package/runtime/sdk/ui/UITabs.ts +0 -236
- package/runtime/sdk/ui/UIText.ts +0 -51
- package/runtime/sdk/ui/UIVideo.ts +0 -88
- package/runtime/sdk/ui/UIVirtualizedList.ts +0 -241
- package/runtime/sdk/ui/UIWidget.ts +0 -127
- package/runtime/sdk/ui/fonts.ts +0 -13
- package/runtime/sdk/ui/presentable.ts +0 -117
- package/runtime/sdk/ui/router.ts +0 -132
- package/runtime/sdk/ui/theme.ts +0 -84
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
// A material instance over creator-gl. Uniforms are set through a Proxy that lowers each JS value to
|
|
2
|
-
// the right native uniform call. The common materials are static factories (Material.lit/unlit/
|
|
3
|
-
// video/shadow); Material.load brings in a custom compiled shader. Ported from worker/src/Material.ts,
|
|
4
|
-
// with the Lit/Unlit/... subclasses collapsed into factories and color accepting any ColorInput.
|
|
5
|
-
|
|
6
|
-
import { Color, type ColorInput } from "../core/color"
|
|
7
|
-
import { fetch, type FetchResponse } from "../runtime/fetch"
|
|
8
|
-
import { Texture } from "./Texture"
|
|
9
|
-
// Type-only (erased at build) so a 3D material never pulls the 2D-canvas runtime; the guard is inline.
|
|
10
|
-
import type { Canvas } from "../canvas/Canvas"
|
|
11
|
-
|
|
12
|
-
/** Duck-type a Canvas without importing it (keeps 3D material free of 2D-canvas code). */
|
|
13
|
-
const isCanvasSource = (v: unknown): v is Canvas =>
|
|
14
|
-
typeof v === "object" && v !== null && (v as { __canvas?: unknown }).__canvas === true
|
|
15
|
-
|
|
16
|
-
type UniformValue = string | Texture | number | boolean | number[] | Float32Array | null
|
|
17
|
-
|
|
18
|
-
const applyUniform = (id: number, key: string, value: UniformValue): void => {
|
|
19
|
-
if (typeof value === "string") {
|
|
20
|
-
if (value.length > 7) _creator.setUniformRgba(id, key, parseInt(value.slice(1), 16))
|
|
21
|
-
else _creator.setUniformRgb(id, key, parseInt(value.slice(1), 16))
|
|
22
|
-
} else if (typeof value === "number") {
|
|
23
|
-
_creator.setUniformFloat(id, key, value)
|
|
24
|
-
} else if (typeof value === "boolean") {
|
|
25
|
-
_creator.setUniformBoolean(id, key, value)
|
|
26
|
-
} else if (value instanceof Texture) {
|
|
27
|
-
_creator.setUniformTexture(id, key, value._id, value.wrapS, value.wrapT)
|
|
28
|
-
} else if (value instanceof Float32Array) {
|
|
29
|
-
_creator.setUniformArray(id, key, value)
|
|
30
|
-
} else if (Array.isArray(value)) {
|
|
31
|
-
_creator.setUniformArray(id, key, Float32Array.of(...value))
|
|
32
|
-
} else {
|
|
33
|
-
_creator.setUniformNull(id, key)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type MaterialColorOptions = { color?: ColorInput, map?: Texture | Canvas | null }
|
|
38
|
-
|
|
39
|
-
/** `Material.particles` options — the default point-sprite material for particle systems. */
|
|
40
|
-
export type ParticlesMaterialOptions = {
|
|
41
|
-
/** Sprite texture — a single image or a flipbook sheet of frames. Unset = soft round dot. */
|
|
42
|
-
map?: Texture | null
|
|
43
|
-
/** Flipbook grid: `N` = an N×N sheet, `[cols, rows]` = a non-square one. Frames run
|
|
44
|
-
* left-to-right, top-to-bottom; drive the index via `particles.frame`. Default 1. */
|
|
45
|
-
sheet?: number | [number, number]
|
|
46
|
-
/** Extra brightness multiplier for a glow look (0 = off). */
|
|
47
|
-
emissive?: number
|
|
48
|
-
/** (`render` quad / stretch) a second sheet on the same grid, ADDED as `emissiveMap × emissiveColor`
|
|
49
|
-
* — keyed by `map`'s alpha, not tinted by the particle colour. A fireball = a smoke `map` whose
|
|
50
|
-
* colour curve goes dark + a fire `emissiveMap` that keeps glowing while alpha lasts. */
|
|
51
|
-
emissiveMap?: Texture | null
|
|
52
|
-
/** Multiplier for `emissiveMap`; an `[r, g, b]` array may exceed 1 (HDR glow). Default 0 (off). */
|
|
53
|
-
emissiveColor?: ColorInput
|
|
54
|
-
/** (`render` quad / stretch) crossfade each flipbook frame into the next by the fractional frame
|
|
55
|
-
* index instead of snapping — smooth sheet playback at any frame rate. Default false. */
|
|
56
|
-
frameBlend?: boolean
|
|
57
|
-
/** Compositing: `"alpha"` (default — smoke, dust) or `"add"` (fire, sparks, magic). */
|
|
58
|
-
blend?: "alpha" | "add"
|
|
59
|
-
/** Soft radial falloff toward the sprite edge. Defaults to true without a map, false with one. */
|
|
60
|
-
soft?: boolean
|
|
61
|
-
/** Soft particles: fade each sprite out over this many metres as it cuts into the scene geometry
|
|
62
|
-
* behind it (Unity's "Soft Particles Factor"), so smoke and dust no longer slice through the
|
|
63
|
-
* ground and walls with a hard edge. 0 = off (default). Reads the scene's depth buffer, which the
|
|
64
|
-
* engine keeps bound while any soft system is on screen — the extra depth pass is only paid then.
|
|
65
|
-
* Filament hosts (desktop / web / Android / Apple); web-lite draws such sprites unfaded. */
|
|
66
|
-
depthFade?: number
|
|
67
|
-
/** How each particle is drawn: `'point'` (default — GPU point sprites, cheapest), `'quad'`
|
|
68
|
-
* (real camera-facing quads — no driver size cap, geometric rotation), or `'stretch'`
|
|
69
|
-
* (quads stretched along velocity — sparks, rain, speed streaks). `'ribbon'` is what `Trail`
|
|
70
|
-
* uses internally. */
|
|
71
|
-
render?: "point" | "quad" | "stretch" | "ribbon"
|
|
72
|
-
/** (`render: 'stretch'`) extra sprite length in world units per unit of speed:
|
|
73
|
-
* length = size + stretch·|velocity|. Default 0.05. */
|
|
74
|
-
stretch?: number
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** @internal — the sheet option as whole [cols, rows], both ≥ 1. The particles shader divides
|
|
78
|
-
* by these with no guard of its own, so this clamp is the only thing between it and a NaN UV. */
|
|
79
|
-
export const _sheetColsRows = (sheet: number | [number, number] | undefined): [number, number] => {
|
|
80
|
-
const [ c, r ] = typeof sheet === "number" ? [ sheet, sheet ] : sheet ?? [ 1, 1 ]
|
|
81
|
-
return [ Math.max(1, Math.floor(c) || 1), Math.max(1, Math.floor(r) || 1) ]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** `Material.lit` options — PBR scalars on top of the color/map pair. */
|
|
85
|
-
export type LitMaterialOptions = MaterialColorOptions & {
|
|
86
|
-
/** Perceptual roughness, 0 (mirror) … 1 (matte). Unset = the shader's default. */
|
|
87
|
-
roughness?: number
|
|
88
|
-
/** Metallic factor, 0 (dielectric) … 1 (metal). Unset = the shader's default. */
|
|
89
|
-
metallic?: number
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export class Material {
|
|
93
|
-
/** @internal native material-instance handle. */
|
|
94
|
-
_id: number
|
|
95
|
-
readonly shader: FetchResponse | "unknown"
|
|
96
|
-
readonly uniforms: Record<string, UniformValue>
|
|
97
|
-
|
|
98
|
-
private _colorKey: string | null = null
|
|
99
|
-
private _useMapFlag = false
|
|
100
|
-
|
|
101
|
-
constructor(shader: FetchResponse | number) {
|
|
102
|
-
if (typeof shader === "number") {
|
|
103
|
-
this.shader = "unknown"
|
|
104
|
-
this._id = shader
|
|
105
|
-
} else {
|
|
106
|
-
this.shader = shader
|
|
107
|
-
this._id = _creator.createMaterial((shader as any)._id)
|
|
108
|
-
}
|
|
109
|
-
const store: Record<string, UniformValue> = {}
|
|
110
|
-
const id = () => this._id
|
|
111
|
-
this.uniforms = new Proxy(store, {
|
|
112
|
-
get: (t, k: string) => t[k],
|
|
113
|
-
set: (t, k: string, v: UniformValue) => { t[k] = v; applyUniform(id(), k, v); return true },
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** Set a uniform (chainable). */
|
|
118
|
-
set(key: string, value: UniformValue): this {
|
|
119
|
-
this.uniforms[key] = value
|
|
120
|
-
return this
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
set color(c: ColorInput) {
|
|
124
|
-
if (this._colorKey) this.uniforms[this._colorKey] = Color.toHexString(c)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// lit/unlit shade baseColor × baseColorMap (factor×map; engines default both to white), so
|
|
128
|
-
// removing the map means resetting baseColorMap to the white 1×1. The useBaseColorMap writes
|
|
129
|
-
// stay for older hosts whose shaders still branch on the flag — current engines ignore it.
|
|
130
|
-
set map(value: Texture | Canvas | null) {
|
|
131
|
-
if (value === null) {
|
|
132
|
-
this.uniforms.baseColorMap = null
|
|
133
|
-
if (this._useMapFlag) this.uniforms.useBaseColorMap = false
|
|
134
|
-
} else {
|
|
135
|
-
// A Canvas bakes to a (cached) 3D texture on assign — same as Sprite accepting a Canvas in 2D.
|
|
136
|
-
this.uniforms.baseColorMap = isCanvasSource(value) ? Texture.fromCanvas(value) : value
|
|
137
|
-
if (this._useMapFlag) this.uniforms.useBaseColorMap = true
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// --- factories ---
|
|
142
|
-
|
|
143
|
-
/** PBR lit material. */
|
|
144
|
-
static lit(options: LitMaterialOptions = {}): Material {
|
|
145
|
-
// The fetchLocal literal must be inline so the compiler's preload header captures the shader name.
|
|
146
|
-
const m = new Material({ _id: _creatorUtils.fetchLocal("lit.filamat") } as any)
|
|
147
|
-
m._colorKey = "baseColor"
|
|
148
|
-
if (options.color !== undefined) m.color = options.color
|
|
149
|
-
if (options.map) m.map = options.map
|
|
150
|
-
if (options.roughness !== undefined) m.uniforms.roughness = options.roughness
|
|
151
|
-
if (options.metallic !== undefined) m.uniforms.metallic = options.metallic
|
|
152
|
-
return m
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** Unlit (flat) material. */
|
|
156
|
-
static unlit(options: MaterialColorOptions = {}): Material {
|
|
157
|
-
const m = new Material({ _id: _creatorUtils.fetchLocal("unlit.filamat") } as any)
|
|
158
|
-
m._colorKey = "baseColor"
|
|
159
|
-
if (options.color !== undefined) m.color = options.color
|
|
160
|
-
if (options.map) m.map = options.map
|
|
161
|
-
return m
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** Default particle material — camera-facing point sprites with tint/opacity/rotation/flipbook
|
|
165
|
-
* driven by the particle curves. Uniforms all default to 0 on a fresh instance, so every look
|
|
166
|
-
* knob is primed here; JS writes after construction override them. */
|
|
167
|
-
static particles(options: ParticlesMaterialOptions = {}): Material {
|
|
168
|
-
const quad = options.render !== undefined && options.render !== "point"
|
|
169
|
-
// Both fetchLocal literals inline so the compiler's preload header captures the shader names.
|
|
170
|
-
const m = quad
|
|
171
|
-
? new Material({ _id: _creatorUtils.fetchLocal("particles-quad.filamat") } as any)
|
|
172
|
-
: new Material({ _id: _creatorUtils.fetchLocal("particles.filamat") } as any)
|
|
173
|
-
m._useMapFlag = false
|
|
174
|
-
m.uniforms.sheetSize = _sheetColsRows(options.sheet)
|
|
175
|
-
m.uniforms.emissive = options.emissive ?? 0
|
|
176
|
-
m.uniforms.additive = options.blend === "add" ? 1 : 0
|
|
177
|
-
m.uniforms.softness = (options.soft ?? !options.map) ? 1 : 0
|
|
178
|
-
m.uniforms.depthFade = options.depthFade ?? 0
|
|
179
|
-
if (quad) {
|
|
180
|
-
m.uniforms.mode = options.render === "ribbon" ? 2 : options.render === "stretch" ? 1 : 0
|
|
181
|
-
m.uniforms.stretch = options.stretch ?? (options.render === "stretch" ? 0.05 : 0)
|
|
182
|
-
if (options.emissiveMap) m.uniforms.emissiveMap = options.emissiveMap
|
|
183
|
-
if (options.emissiveColor !== undefined) m.uniforms.emissiveColor = Color.toRgb01(options.emissiveColor)
|
|
184
|
-
if (options.frameBlend) m.uniforms.frameBlend = 1
|
|
185
|
-
}
|
|
186
|
-
if (options.map) m.map = options.map
|
|
187
|
-
return m
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** Material that samples a VideoPlayer's texture. */
|
|
191
|
-
static video(map?: Texture): Material {
|
|
192
|
-
const m = new Material({ _id: _creatorUtils.fetchLocal("video.filamat") } as any)
|
|
193
|
-
m._useMapFlag = false
|
|
194
|
-
if (map) m.uniforms.baseColorMap = map
|
|
195
|
-
return m
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/** The lightmap material (docs/lightmap-plan.md): PBR base colour × a baked shadow/AO atlas on UV1.
|
|
199
|
-
* Models take it through `Model.load(…, { lightmap: true })`; `Lightmap.load` builds one per static
|
|
200
|
-
* Mesh. Parameters use gltfio's names (`baseColorFactor`, `baseColorMap`, `roughnessFactor`,
|
|
201
|
-
* `metallicFactor`) plus `lightmap`, `lightmapST`, `ambientScale`, `sunStrength` (the sun / IBL terms come from
|
|
202
|
-
* filament's per-frame uniforms inside the shader). */
|
|
203
|
-
static lightmap(): Material {
|
|
204
|
-
// Inline literal: the compiler's preload header captures the shader name from it.
|
|
205
|
-
const m = new Material({ _id: _creatorUtils.fetchLocal("lightmap.filamat") } as any)
|
|
206
|
-
m.set("baseColorFactor", "#ffffffff").set("roughnessFactor", 1).set("metallicFactor", 0)
|
|
207
|
-
m.set("lightmapST", [ 1, 1, 0, 0 ]).set("ambientScale", 1).set("sunStrength", 1).set("hasNormalMap", 0)
|
|
208
|
-
m.set("probeMin", [ 0, 0, 0, 0 ]).set("probeInvSize", [ 0, 0, 0, 0 ])
|
|
209
|
-
return m
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** The terrain splat material (docs/terrain-plan.md §1.5): four albedo (+ normal-map) layers blended by
|
|
213
|
-
* a control map on the terrain's own grid, per-layer `tiling` (metres per repeat) / `roughness` /
|
|
214
|
-
* `normalScale` / `triplanar`, lightmap-aware (the same `lightmap` / `lightmapST` block as
|
|
215
|
-
* `Material.lightmap`). `Terrain` builds and owns one per terrain; the uniforms are primed here so an
|
|
216
|
-
* unset layer is white and an unbaked terrain is fully lit. */
|
|
217
|
-
static terrain(): Material {
|
|
218
|
-
// Inline literal: the compiler's preload header captures the shader name from it.
|
|
219
|
-
const m = new Material({ _id: _creatorUtils.fetchLocal("terrain.filamat") } as any)
|
|
220
|
-
m.set("tiling", [ 8, 8, 8, 8 ]).set("roughness", [ 1, 1, 1, 1 ]).set("normalScale", [ 0, 0, 0, 0 ]).set("triplanar", [ 0, 0, 0, 0 ])
|
|
221
|
-
m.set("gridSize", [ 2, 2 ]).set("cellSize", 1).set("tint", "#ffffff")
|
|
222
|
-
m.set("lightmapST", [ 1, 1, 0, 0 ]).set("ambientScale", 1).set("sunStrength", 1)
|
|
223
|
-
return m
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/** @internal the shared template instance `Model.load({ lightmap })` hands the engine (its MATERIAL is what
|
|
227
|
-
* the GLB provider instantiates; the template itself never draws). */
|
|
228
|
-
static _lightmapTemplate(): Material { return (Material._lmTemplate ??= Material.lightmap()) }
|
|
229
|
-
private static _lmTemplate: Material | undefined
|
|
230
|
-
|
|
231
|
-
/** Shadow-catcher material (transparent except where shadows fall). */
|
|
232
|
-
static shadow(color: ColorInput = "#000000aa"): Material {
|
|
233
|
-
const m = new Material({ _id: _creatorUtils.fetchLocal("shadow.filamat") } as any)
|
|
234
|
-
m._colorKey = "color"
|
|
235
|
-
m.color = color
|
|
236
|
-
return m
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** Load a custom compiled shader (.mat URL) as a material. */
|
|
240
|
-
static load(url: string): Promise<Material> {
|
|
241
|
-
// "id:<n>" — the artifact is a LOCAL file the host already resolved through fetchLocal (a
|
|
242
|
-
// compile with no asset server: the desktop host reads it from next to the bundle). There is
|
|
243
|
-
// nothing to fetch, so the material is ready synchronously; -1 means the host found no such
|
|
244
|
-
// file, which would otherwise reach createMaterial as a bad handle.
|
|
245
|
-
if (url.startsWith("id:")) {
|
|
246
|
-
const id = Number(url.slice(3))
|
|
247
|
-
if (!(id >= 0)) {
|
|
248
|
-
return Promise.reject(new Error(`Shader not found next to the app (${url}). Compile it with \`lecodes shaders compile\`.`))
|
|
249
|
-
}
|
|
250
|
-
return Promise.resolve(new Material({ _id: id } as any))
|
|
251
|
-
}
|
|
252
|
-
return fetch(url, { useOnce: true }).then((resp) => {
|
|
253
|
-
if (resp.status >= 400) return Promise.reject(new Error(`Failed to fetch shader from ${url}. HTTP ${resp.status}`))
|
|
254
|
-
return new Material(resp)
|
|
255
|
-
})
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/** @internal */
|
|
259
|
-
static idOf(material: Material): number { return material._id }
|
|
260
|
-
}
|
package/runtime/sdk/gl/Mesh.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// A renderable 3D node from raw geometry — the primitive shapes (box/sphere/cylinder/plane) and
|
|
2
|
-
// Mesh.from for a custom Geometry. A GLB import is a different kind: see Model.load.
|
|
3
|
-
|
|
4
|
-
import { cx, cy, cz, type Vec3Like } from "../math/vec"
|
|
5
|
-
import {
|
|
6
|
-
Geometry,
|
|
7
|
-
type CylinderOptions,
|
|
8
|
-
type PlaneOptions,
|
|
9
|
-
type SphereOptions,
|
|
10
|
-
} from "./Geometry"
|
|
11
|
-
import { Material } from "./Material"
|
|
12
|
-
import { Node } from "./Node"
|
|
13
|
-
|
|
14
|
-
/** Common transform/render options every primitive factory accepts. */
|
|
15
|
-
export type MeshOptions = {
|
|
16
|
-
material?: Material
|
|
17
|
-
position?: Vec3Like
|
|
18
|
-
eulerAngles?: Vec3Like
|
|
19
|
-
scale?: Vec3Like | number
|
|
20
|
-
name?: string
|
|
21
|
-
castShadows?: boolean
|
|
22
|
-
receiveShadows?: boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class Mesh extends Node {
|
|
26
|
-
private _geometry?: Geometry
|
|
27
|
-
|
|
28
|
-
constructor(geometry?: Geometry, material?: Material) {
|
|
29
|
-
super()
|
|
30
|
-
if (geometry) {
|
|
31
|
-
const mat = material ?? Material.unlit()
|
|
32
|
-
this._geometry = geometry
|
|
33
|
-
this._materials = [ mat ]
|
|
34
|
-
_creator.setMesh(this.id, Material.idOf(mat), geometry.vertices, geometry.normals, geometry.indices, geometry.uv, geometry._meshKind, geometry.uv1)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
override get geometry(): Geometry | undefined { return this._geometry }
|
|
39
|
-
|
|
40
|
-
/** A Mesh always carries a material (slot 0) — see Node.setMaterial for the slot API. */
|
|
41
|
-
override get material(): Material { return this._materials![0]! }
|
|
42
|
-
override set material(m: Material) { this.setMaterial(m, 0) }
|
|
43
|
-
|
|
44
|
-
set culling(v: boolean) { _creator.setCulling(this.id, v) }
|
|
45
|
-
set castShadows(v: boolean) { _creator.setCastShadows(this.id, v) }
|
|
46
|
-
set receiveShadows(v: boolean) { _creator.setReceiveShadows(this.id, v) }
|
|
47
|
-
|
|
48
|
-
// --- factories ---
|
|
49
|
-
|
|
50
|
-
static box(options: MeshOptions & { size?: Vec3Like | number } = {}): Mesh {
|
|
51
|
-
// the size goes into the geometry (not a scale after): the lightmap chart is laid out per face area
|
|
52
|
-
return apply(new Mesh(Geometry.box(options.size ?? 1), options.material), options)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static sphere(options: MeshOptions & SphereOptions = {}): Mesh {
|
|
56
|
-
return apply(new Mesh(Geometry.sphere(options), options.material), options)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static cylinder(options: MeshOptions & CylinderOptions = {}): Mesh {
|
|
60
|
-
return apply(new Mesh(Geometry.cylinder(options), options.material), options)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static plane(options: MeshOptions & PlaneOptions = {}): Mesh {
|
|
64
|
-
return apply(new Mesh(Geometry.plane(options), options.material), options)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Wrap a custom Geometry. */
|
|
68
|
-
static from(geometry: Geometry, options: MeshOptions = {}): Mesh {
|
|
69
|
-
return apply(new Mesh(geometry, options.material), options)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const sizeToVec = (s: Vec3Like | number): [number, number, number] => (typeof s === "number" ? [ s, s, s ] : [ cx(s), cy(s), cz(s) ])
|
|
74
|
-
|
|
75
|
-
const apply = (mesh: Mesh, o: MeshOptions): Mesh => {
|
|
76
|
-
if (o.position) mesh.position = o.position
|
|
77
|
-
if (o.eulerAngles) mesh.eulerAngles = o.eulerAngles
|
|
78
|
-
if (o.scale !== undefined) mesh.scale = typeof o.scale === "number" ? [ o.scale, o.scale, o.scale ] : o.scale
|
|
79
|
-
if (o.name !== undefined) mesh.name = o.name
|
|
80
|
-
if (o.castShadows !== undefined) mesh.castShadows = o.castShadows
|
|
81
|
-
if (o.receiveShadows !== undefined) mesh.receiveShadows = o.receiveShadows
|
|
82
|
-
return mesh
|
|
83
|
-
}
|
package/runtime/sdk/gl/Model.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// A loaded GLB model — its own node kind (a GLB is a node hierarchy with baked animation clips),
|
|
2
|
-
// distinct from Mesh (raw primitives, no animation). Animation is always present, reached as
|
|
3
|
-
// model.anim (an Animator over the GLB's clips — crossfades, blend spaces, layers when you need them):
|
|
4
|
-
// const hero = await Model.load(asset('./hero.glb'))
|
|
5
|
-
// hero.anim.play('Run', { loop: true })
|
|
6
|
-
|
|
7
|
-
import { fetch, type FetchResponse } from "../runtime/fetch"
|
|
8
|
-
import { Node } from "./Node"
|
|
9
|
-
import { Animator, _pushLod, type LodMode } from "./animation/Animator"
|
|
10
|
-
import { Material } from "./Material"
|
|
11
|
-
|
|
12
|
-
export class Model extends Node {
|
|
13
|
-
/** The model's Animator — always present, its clip table = the GLB's embedded clips. Configure
|
|
14
|
-
* more (external clips, blend spaces, layers) with `model.aspect(Animator, {...})`. */
|
|
15
|
-
declare readonly anim: Animator
|
|
16
|
-
/** @internal loaded through the lightmap material (docs/lightmap-plan.md); clones inherit it. */
|
|
17
|
-
_lightmapped = false
|
|
18
|
-
/** @internal what `load` does without an explicit `lightmap` option: `'dynamic'` while a scene file with
|
|
19
|
-
* `env.lightmap.volume` runs (Lightmap sets it), so weapons, spawns and make() subtrees read the volume. */
|
|
20
|
-
static _lightmapDefault: false | "dynamic" = false
|
|
21
|
-
/** @internal the shadow pair, mirrored here because the bridge writes both at once. */
|
|
22
|
-
_castShadows = true
|
|
23
|
-
/** @internal */
|
|
24
|
-
_receiveShadows = true
|
|
25
|
-
/** @internal */
|
|
26
|
-
_culling = true
|
|
27
|
-
/** @internal -1 = auto (see `lod`) */
|
|
28
|
-
_lodMesh = -1
|
|
29
|
-
|
|
30
|
-
constructor(internalId: number) {
|
|
31
|
-
super(internalId)
|
|
32
|
-
this.aspect(Animator)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Does this model cast a real-time shadow? Unlike Mesh (one renderable) a GLB is a whole
|
|
36
|
-
* hierarchy, so the flag goes to EVERY renderable of the instance. A first-person viewmodel —
|
|
37
|
-
* arms, weapon, attachments — sets it false: it lives in front of the camera and its shadow
|
|
38
|
-
* is never wanted. */
|
|
39
|
-
get castShadows(): boolean { return this._castShadows }
|
|
40
|
-
set castShadows(v: boolean) { this._castShadows = v; this._applyShadows() }
|
|
41
|
-
|
|
42
|
-
/** Is this model lit by other casters' shadows? Same instance-wide reach as castShadows. */
|
|
43
|
-
get receiveShadows(): boolean { return this._receiveShadows }
|
|
44
|
-
set receiveShadows(v: boolean) { this._receiveShadows = v; this._applyShadows() }
|
|
45
|
-
|
|
46
|
-
/** Frustum culling for the whole instance: a model the camera cannot see skips the draw and the
|
|
47
|
-
* shadow pass. ON by default where the host keeps a skinned mesh's bounds honest — the engine refits
|
|
48
|
-
* them to the joints every frame, so a walking, kneeling or ragdolled body is never culled while on
|
|
49
|
-
* screen (`_creator.skinnedCullingSupported`); OFF (always draw) on hosts without that, where
|
|
50
|
-
* Filament would cull an animated body by its bind-pose box. `false` = always draw (a skybox-sized
|
|
51
|
-
* mesh, a debugging aid); `true` forces it on regardless of the host. */
|
|
52
|
-
get culling(): boolean { return this._culling }
|
|
53
|
-
set culling(v: boolean) { this._culling = v; _creator.setGlbCulling(this.id, v) }
|
|
54
|
-
/** Level of detail (docs/lod-plan.md). `'auto'` (default): the engine shows the `_LOD<n>` mesh level
|
|
55
|
-
* that fits the model's size on screen (`lecodes assets doctor --lod` makes them) and scales the
|
|
56
|
-
* animation rate with it; a number 0–3 pins that level for both — `0` = always full detail (a hero,
|
|
57
|
-
* a showcase), `2`/`3` = always cheap (a crowd filler). `model.anim.lod = 'full'` keeps the animation
|
|
58
|
-
* exact while the mesh still switches. No-op on hosts without the LOD pass. */
|
|
59
|
-
get lod(): LodMode { return this._lodMesh < 0 ? "auto" : (this._lodMesh as 0 | 1 | 2 | 3) }
|
|
60
|
-
set lod(v: LodMode) { this._lodMesh = v === "auto" ? -1 : Math.max(0, Math.min(3, Math.round(v))); _pushLod(this) }
|
|
61
|
-
|
|
62
|
-
/** @internal the default for a fresh instance (load / clone), decided once per host. */
|
|
63
|
-
static _cullingDefault(): boolean {
|
|
64
|
-
if (Model._cullDefault === undefined) Model._cullDefault = !!_creator.skinnedCullingSupported?.()
|
|
65
|
-
return Model._cullDefault
|
|
66
|
-
}
|
|
67
|
-
private static _cullDefault: boolean | undefined
|
|
68
|
-
|
|
69
|
-
/** @internal both flags travel together — the bridge walks the instance once. */
|
|
70
|
-
_applyShadows(): void { _creator.setGlbShadows?.(this.id, this._castShadows, this._receiveShadows) }
|
|
71
|
-
|
|
72
|
-
/** Duplicate this model — a deep copy of the GLB (meshes, skeleton, animation clips), attached to
|
|
73
|
-
* the same parent and scene and sharing this model's current transform. The clone has its own
|
|
74
|
-
* independent animation state (reach it via clone.anim). Mirrors this model's culling flag. */
|
|
75
|
-
clone(): Model {
|
|
76
|
-
const id = _creator.cloneEntity(this.id)
|
|
77
|
-
const m = new Model(id)
|
|
78
|
-
m._lightmapped = this._lightmapped
|
|
79
|
-
if (!this._culling) { m._culling = false; _creator.setGlbCulling(id, false) } // the engine default is on
|
|
80
|
-
if (this._lodMesh >= 0) { m._lodMesh = this._lodMesh; _pushLod(m) }
|
|
81
|
-
// the clone is a FRESH gltfio instance — it comes back with the asset's own shadow flags,
|
|
82
|
-
// not this model's, so a cleared flag has to be re-applied
|
|
83
|
-
m._castShadows = this._castShadows
|
|
84
|
-
m._receiveShadows = this._receiveShadows
|
|
85
|
-
if (!this._castShadows || !this._receiveShadows) m._applyShadows()
|
|
86
|
-
return m
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** Load a GLB model. Returns its root as a Model; play its baked clips via model.anim. */
|
|
90
|
-
static load(
|
|
91
|
-
source: string | FetchResponse,
|
|
92
|
-
options: {
|
|
93
|
-
/** Frustum culling — see `culling` (default: on where the host refits skinned bounds, else off). */
|
|
94
|
-
culling?: boolean
|
|
95
|
-
onProgress?: (p: { loaded: number, total?: number }) => void
|
|
96
|
-
/** Baked lighting (docs/lightmap-plan.md). `true` = a STATIC: loads through the lightmap material so
|
|
97
|
-
* `Lightmap.load` can bind its atlas rect (the GLB needs TEXCOORD_1 — `lecodes assets doctor
|
|
98
|
-
* --lightmap-uv`). `'dynamic'` = a mover: the same material, lit by the level's light VOLUME instead
|
|
99
|
-
* (no UV1 needed). Omitted: `'dynamic'` while a scene file with `env.lightmap.volume` is running,
|
|
100
|
-
* else off. `false` = the standard shader. Hosts without lightmap support ignore it. */
|
|
101
|
-
lightmap?: boolean | "dynamic"
|
|
102
|
-
} = {},
|
|
103
|
-
): Promise<Model> {
|
|
104
|
-
if (typeof source === "string") {
|
|
105
|
-
return fetch(source, { useOnce: true, onProgress: options.onProgress }).then((resp) => {
|
|
106
|
-
if (resp.status >= 400) return Promise.reject(new Error(`Failed to load GLB from ${source}. HTTP ${resp.status}`))
|
|
107
|
-
return Model.load(resp, options)
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
return new Promise<Model>((resolve, reject) => {
|
|
111
|
-
const mode = options.lightmap ?? Model._lightmapDefault
|
|
112
|
-
const lightmapped = !!mode && !!_creator.setNextGlbLightmapped
|
|
113
|
-
if (lightmapped) _creator.setNextGlbLightmapped!(Material.idOf(Material._lightmapTemplate()))
|
|
114
|
-
_creator.createGlb((source as unknown as { _id: number })._id, (entityId: number) => {
|
|
115
|
-
if (entityId === 0) { reject(new Error("Failed to load GLB")); return }
|
|
116
|
-
const model = new Model(entityId)
|
|
117
|
-
model._lightmapped = lightmapped
|
|
118
|
-
const culling = options.culling ?? Model._cullingDefault()
|
|
119
|
-
if (!culling) { model._culling = false; _creator.setGlbCulling(entityId, false) }
|
|
120
|
-
resolve(model)
|
|
121
|
-
}, reject)
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
}
|