@babylonjs-toolkit/next 9.25.1 → 9.28.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/lib/index.d.ts +35 -21
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +35 -21
- package/lib/particleconstantcurve.d.ts +3 -0
- package/lib/particleconstantcurve.d.ts.map +1 -0
- package/lib/particleconstantcurve.js +3 -0
- package/lib/particleconstantgradient.d.ts +3 -0
- package/lib/particleconstantgradient.d.ts.map +1 -0
- package/lib/particleconstantgradient.js +4 -0
- package/lib/particleemptytexture.d.ts +3 -0
- package/lib/particleemptytexture.d.ts.map +1 -0
- package/lib/particleemptytexture.js +1 -0
- package/lib/particlev2.d.ts +3 -0
- package/lib/particlev2.d.ts.map +1 -0
- package/lib/particlev2.js +1 -0
- package/lib/particlev3.d.ts +3 -0
- package/lib/particlev3.d.ts.map +1 -0
- package/lib/particlev3.js +1 -0
- package/lib/particlewhite.d.ts +3 -0
- package/lib/particlewhite.d.ts.map +1 -0
- package/lib/particlewhite.js +1 -0
- package/lib/project.d.ts +4 -118
- package/lib/project.d.ts.map +1 -1
- package/lib/project.js +65 -222
- package/lib/scenemanager.d.ts +6061 -831
- package/lib/scenemanager.d.ts.map +1 -1
- package/lib/scenemanager.js +44166 -15351
- package/lib/sgshadowdepth.d.ts +19 -0
- package/lib/sgshadowdepth.d.ts.map +1 -0
- package/lib/sgshadowdepth.js +214 -0
- package/lib/shadergraphfullscreen.d.ts +18 -0
- package/lib/shadergraphfullscreen.d.ts.map +1 -0
- package/lib/shadergraphfullscreen.js +22 -0
- package/lib/shadergraphlighttable.d.ts +7 -0
- package/lib/shadergraphlighttable.d.ts.map +1 -0
- package/lib/shadergraphlighttable.js +74 -0
- package/lib/unityscrollbar.d.ts.map +1 -1
- package/package.json +13 -13
- package/lib/iparticlesystemtransform.d.ts +0 -9
- package/lib/iparticlesystemtransform.d.ts.map +0 -1
- package/lib/iparticlesystemtransform.js +0 -1
- package/lib/perlin2d.d.ts +0 -9
- package/lib/perlin2d.d.ts.map +0 -1
- package/lib/perlin2d.js +0 -45
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Material } from '@babylonjs/core/Materials/material';
|
|
2
|
+
import { SubMesh } from '@babylonjs/core/Meshes/subMesh';
|
|
3
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
4
|
+
import { ShadowDepthWrapper } from '@babylonjs/core/Materials';
|
|
5
|
+
import { Light } from '@babylonjs/core/Lights/light';
|
|
6
|
+
export declare class SgShadowDepth {
|
|
7
|
+
static Enabled: boolean;
|
|
8
|
+
static Create(material: Material, scene: Scene): ShadowDepthWrapper;
|
|
9
|
+
static Token(options: string, baseKey: string): string;
|
|
10
|
+
static Hash(text: string): string;
|
|
11
|
+
static IsDefinesObject(defines: any): boolean;
|
|
12
|
+
static BaseDefines(wrapper: any, subMesh: SubMesh): any;
|
|
13
|
+
static ResolveHolderDefines(wrapper: any, subMesh: SubMesh, shadowGenerator: any): boolean;
|
|
14
|
+
static BaseDefinesStale(wrapper: any, subMesh: SubMesh): boolean;
|
|
15
|
+
static LightsMatch(defines: any, lights: Light[]): boolean;
|
|
16
|
+
static FilterDefines(defines: string): string;
|
|
17
|
+
static Share(wrapper: any, scene: Scene, options: string): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=sgshadowdepth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sgshadowdepth.d.ts","sourceRoot":"","sources":["../src/sgshadowdepth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAkB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAWrD,qBAAa,aAAa;IAOlB,OAAc,OAAO,EAAE,OAAO,CAAS;WAGzB,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,kBAAkB;WAY5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;WAK/C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;WAa1B,eAAe,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;WAQtC,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,GAAG;WAqBhD,oBAAoB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,GAAG,OAAO;WAwBnF,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;WAezD,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO;WAenD,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;WAKtC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;CA6GzE"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { ShadowDepthWrapper, ShaderLanguage } from '@babylonjs/core/Materials';
|
|
2
|
+
export class SgShadowDepth {
|
|
3
|
+
static Create(material, scene) {
|
|
4
|
+
if (SgShadowDepth.Enabled !== true)
|
|
5
|
+
return null;
|
|
6
|
+
const wgsl = (material.shaderLanguage === ShaderLanguage.WGSL);
|
|
7
|
+
const options = { standalone: true };
|
|
8
|
+
if (wgsl)
|
|
9
|
+
options.remappedVariables = ["vNormalW", "vertexOutputs.vNormalW"];
|
|
10
|
+
const wrapper = new ShadowDepthWrapper(material, scene, options);
|
|
11
|
+
SgShadowDepth.Share(wrapper, scene, (wgsl ? "wgsl" : "glsl") + "|" + (options.remappedVariables || []).join(","));
|
|
12
|
+
material.onDisposeObservable.addOnce(() => { wrapper.dispose(); });
|
|
13
|
+
return wrapper;
|
|
14
|
+
}
|
|
15
|
+
static Token(options, baseKey) {
|
|
16
|
+
return "sgShadowDepth|" + options + "|" + SgShadowDepth.Hash(baseKey);
|
|
17
|
+
}
|
|
18
|
+
static Hash(text) {
|
|
19
|
+
let h1 = 0xdeadbeef, h2 = 0x41c6ce57;
|
|
20
|
+
for (let i = 0; i < text.length; i++) {
|
|
21
|
+
const c = text.charCodeAt(i);
|
|
22
|
+
h1 = Math.imul(h1 ^ c, 2654435761);
|
|
23
|
+
h2 = Math.imul(h2 ^ c, 1597334677);
|
|
24
|
+
}
|
|
25
|
+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
|
26
|
+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
|
27
|
+
return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36) + ":" + text.length.toString(36);
|
|
28
|
+
}
|
|
29
|
+
static IsDefinesObject(defines) {
|
|
30
|
+
return (defines != null && typeof defines === "object");
|
|
31
|
+
}
|
|
32
|
+
static BaseDefines(wrapper, subMesh) {
|
|
33
|
+
const entry = (wrapper._subMeshToEffect != null) ? wrapper._subMeshToEffect.get(subMesh) : null;
|
|
34
|
+
if (entry == null || entry[0] == null)
|
|
35
|
+
return null;
|
|
36
|
+
const created = wrapper.__sgCreatedDefines;
|
|
37
|
+
const record = (created != null) ? created.get(subMesh) : null;
|
|
38
|
+
if (record != null && record.effect === entry[0] && SgShadowDepth.IsDefinesObject(record.defines))
|
|
39
|
+
return record.defines;
|
|
40
|
+
const s = subMesh;
|
|
41
|
+
const own = (typeof s._getDrawWrapper === "function") ? s._getDrawWrapper(entry[1]) : null;
|
|
42
|
+
if (own != null && SgShadowDepth.IsDefinesObject(own.defines))
|
|
43
|
+
return own.defines;
|
|
44
|
+
const wrappers = s._drawWrappers || [];
|
|
45
|
+
for (let i = 0; i < wrappers.length; i++) {
|
|
46
|
+
const dw = wrappers[i];
|
|
47
|
+
if (dw != null && dw.effect === entry[0] && SgShadowDepth.IsDefinesObject(dw.defines))
|
|
48
|
+
return dw.defines;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
static ResolveHolderDefines(wrapper, subMesh, shadowGenerator) {
|
|
53
|
+
const holders = wrapper._subMeshToDepthWrapper;
|
|
54
|
+
const holder = (holders != null && typeof holders.get === "function") ? holders.get(subMesh, shadowGenerator) : null;
|
|
55
|
+
if (holder == null || holder.mainDrawWrapper == null)
|
|
56
|
+
return true;
|
|
57
|
+
const main = holder.mainDrawWrapper;
|
|
58
|
+
let defines = main.defines;
|
|
59
|
+
if (!SgShadowDepth.IsDefinesObject(defines)) {
|
|
60
|
+
defines = SgShadowDepth.BaseDefines(wrapper, subMesh);
|
|
61
|
+
if (defines == null)
|
|
62
|
+
return false;
|
|
63
|
+
main.defines = defines;
|
|
64
|
+
}
|
|
65
|
+
const passes = holder.drawWrapper || [];
|
|
66
|
+
for (let i = 0; i < passes.length; i++) {
|
|
67
|
+
const dw = passes[i];
|
|
68
|
+
if (dw != null && !SgShadowDepth.IsDefinesObject(dw.defines))
|
|
69
|
+
dw.defines = defines;
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
static BaseDefinesStale(wrapper, subMesh) {
|
|
74
|
+
const defines = SgShadowDepth.BaseDefines(wrapper, subMesh);
|
|
75
|
+
if (defines == null)
|
|
76
|
+
return false;
|
|
77
|
+
if (defines.isDirty === true)
|
|
78
|
+
return true;
|
|
79
|
+
const mesh = (subMesh != null) ? subMesh.getRenderingMesh() : null;
|
|
80
|
+
return !SgShadowDepth.LightsMatch(defines, (mesh != null) ? mesh.lightSources : null);
|
|
81
|
+
}
|
|
82
|
+
static LightsMatch(defines, lights) {
|
|
83
|
+
if (defines == null)
|
|
84
|
+
return true;
|
|
85
|
+
const list = lights || [];
|
|
86
|
+
for (let i = 0; i < 32; i++) {
|
|
87
|
+
if (defines["LIGHT" + i] !== true)
|
|
88
|
+
break;
|
|
89
|
+
const light = list[i];
|
|
90
|
+
if (light == null)
|
|
91
|
+
return false;
|
|
92
|
+
const kind = (typeof light.getClassName === "function") ? light.getClassName() : "";
|
|
93
|
+
const flag = (kind === "DirectionalLight") ? "DIRLIGHT" : (kind === "HemisphericLight") ? "HEMILIGHT" : (kind === "PointLight") ? "POINTLIGHT" : (kind === "SpotLight") ? "SPOTLIGHT" : null;
|
|
94
|
+
if (flag != null && defines[flag + i] !== true)
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
static FilterDefines(defines) {
|
|
100
|
+
return defines.split("\n").filter((line) => !/^\s*#define\s+(PREPASS|SCENE_MRT_COUNT)/.test(line)).join("\n");
|
|
101
|
+
}
|
|
102
|
+
static Share(wrapper, scene, options) {
|
|
103
|
+
const created = new WeakMap();
|
|
104
|
+
wrapper.__sgCreatedDefines = created;
|
|
105
|
+
const observer = wrapper._onEffectCreatedObserver;
|
|
106
|
+
if (observer != null && typeof observer.callback === "function") {
|
|
107
|
+
const callback = observer.callback;
|
|
108
|
+
observer.callback = function (info) {
|
|
109
|
+
const result = callback.apply(this, arguments);
|
|
110
|
+
const subMesh = (info != null) ? info.subMesh : null;
|
|
111
|
+
if (subMesh != null && info.effect != null) {
|
|
112
|
+
const defines = subMesh.materialDefines;
|
|
113
|
+
if (SgShadowDepth.IsDefinesObject(defines))
|
|
114
|
+
created.set(subMesh, { effect: info.effect, defines: defines });
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const makeEffect = wrapper._makeEffect;
|
|
120
|
+
if (typeof makeEffect === "function") {
|
|
121
|
+
wrapper._makeEffect = function (subMesh, depthDefines, shadowGenerator) {
|
|
122
|
+
const entry = (this._subMeshToEffect != null) ? this._subMeshToEffect.get(subMesh) : null;
|
|
123
|
+
const base = (entry != null) ? entry[0] : null;
|
|
124
|
+
const engine = scene.getEngine();
|
|
125
|
+
const createEffect = engine.createEffect;
|
|
126
|
+
engine.createEffect = function (source, effectOptions) {
|
|
127
|
+
if (effectOptions != null && typeof effectOptions.defines === "string")
|
|
128
|
+
effectOptions.defines = SgShadowDepth.FilterDefines(effectOptions.defines) + "\n#define SG_SHADOWPASS";
|
|
129
|
+
const baseMaterial = wrapper._baseMaterial;
|
|
130
|
+
const processor = (baseMaterial != null && typeof baseMaterial.getGraphFinalCodeProcessor === "function") ? baseMaterial.getGraphFinalCodeProcessor() : null;
|
|
131
|
+
if (effectOptions != null && processor != null && effectOptions.processFinalCode == null)
|
|
132
|
+
effectOptions.processFinalCode = processor;
|
|
133
|
+
const token = (base != null && typeof base._key === "string" && base._key.length > 0) ? SgShadowDepth.Token(options, base._key) : null;
|
|
134
|
+
if (token != null && source != null && typeof source === "object" && (source.vertexSource != null || source.fragmentSource != null)) {
|
|
135
|
+
source.vertexToken = token;
|
|
136
|
+
source.fragmentToken = token;
|
|
137
|
+
}
|
|
138
|
+
return createEffect.apply(engine, arguments);
|
|
139
|
+
};
|
|
140
|
+
let effect = null;
|
|
141
|
+
try {
|
|
142
|
+
effect = makeEffect.apply(this, arguments);
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
engine.createEffect = createEffect;
|
|
146
|
+
}
|
|
147
|
+
if (effect != null && !SgShadowDepth.ResolveHolderDefines(this, subMesh, shadowGenerator))
|
|
148
|
+
return null;
|
|
149
|
+
return effect;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const isReady = wrapper.isReadyForSubMesh;
|
|
153
|
+
if (typeof isReady === "function") {
|
|
154
|
+
wrapper.isReadyForSubMesh = function (subMesh, defines, shadowGenerator, useInstances, passId) {
|
|
155
|
+
const entry = (this._subMeshToEffect != null) ? this._subMeshToEffect.get(subMesh) : null;
|
|
156
|
+
if (entry != null && entry[0] != null && typeof entry[0].isReady === "function" && entry[0].isReady()) {
|
|
157
|
+
if (SgShadowDepth.BaseDefinesStale(this, subMesh)) {
|
|
158
|
+
const renderingMesh = (subMesh != null) ? subMesh.getRenderingMesh() : null;
|
|
159
|
+
const meshInfo = (renderingMesh != null) ? renderingMesh._internalAbstractMeshDataInfo : null;
|
|
160
|
+
if (meshInfo != null && meshInfo._isActive === true)
|
|
161
|
+
return false;
|
|
162
|
+
return isReady.apply(this, arguments);
|
|
163
|
+
}
|
|
164
|
+
const effect = this._makeEffect(subMesh, defines, shadowGenerator, passId);
|
|
165
|
+
return (effect != null && effect.isReady());
|
|
166
|
+
}
|
|
167
|
+
const mesh = (subMesh != null) ? subMesh.getRenderingMesh() : null;
|
|
168
|
+
const info = (mesh != null) ? mesh._internalAbstractMeshDataInfo : null;
|
|
169
|
+
if (entry == null && info != null && info._isActive === true)
|
|
170
|
+
return false;
|
|
171
|
+
return isReady.apply(this, arguments);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const retired = new Set();
|
|
175
|
+
if (typeof wrapper._deleteDepthWrapperEffect === "function") {
|
|
176
|
+
wrapper._deleteDepthWrapperEffect = function (subMesh) {
|
|
177
|
+
const map = (this._subMeshToDepthWrapper != null) ? this._subMeshToDepthWrapper.mm.get(subMesh) : null;
|
|
178
|
+
if (map == null)
|
|
179
|
+
return;
|
|
180
|
+
map.forEach((holder) => {
|
|
181
|
+
const effect = (holder != null && holder.mainDrawWrapper != null) ? holder.mainDrawWrapper.effect : null;
|
|
182
|
+
if (effect == null)
|
|
183
|
+
return;
|
|
184
|
+
if (retired.has(effect))
|
|
185
|
+
effect.dispose();
|
|
186
|
+
else
|
|
187
|
+
retired.add(effect);
|
|
188
|
+
});
|
|
189
|
+
this._subMeshToDepthWrapper.mm.delete(subMesh);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const dispose = wrapper.dispose;
|
|
193
|
+
let disposed = false;
|
|
194
|
+
wrapper.dispose = function () {
|
|
195
|
+
if (disposed)
|
|
196
|
+
return;
|
|
197
|
+
disposed = true;
|
|
198
|
+
dispose.apply(this, arguments);
|
|
199
|
+
if (this._subMeshToDepthWrapper != null) {
|
|
200
|
+
this._subMeshToDepthWrapper.mm.forEach((map) => map.forEach((holder) => {
|
|
201
|
+
const effect = (holder != null && holder.mainDrawWrapper != null) ? holder.mainDrawWrapper.effect : null;
|
|
202
|
+
if (effect != null && !retired.has(effect))
|
|
203
|
+
retired.add(effect);
|
|
204
|
+
else if (effect != null)
|
|
205
|
+
effect.dispose();
|
|
206
|
+
}));
|
|
207
|
+
this._subMeshToDepthWrapper.mm.clear();
|
|
208
|
+
}
|
|
209
|
+
retired.forEach((effect) => effect.dispose());
|
|
210
|
+
retired.clear();
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
SgShadowDepth.Enabled = false;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
+
import { Camera } from '@babylonjs/core/Cameras/camera';
|
|
3
|
+
import { ShaderGraphPass } from './scenemanager';
|
|
4
|
+
import { PostProcess } from '@babylonjs/core';
|
|
5
|
+
export declare class ShaderGraphFullscreen {
|
|
6
|
+
static Create(scene: Scene, className: string, options?: {
|
|
7
|
+
camera?: Camera;
|
|
8
|
+
injection?: string;
|
|
9
|
+
order?: number;
|
|
10
|
+
block?: any;
|
|
11
|
+
}): {
|
|
12
|
+
pass: ShaderGraphPass;
|
|
13
|
+
postProcess: PostProcess;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=shadergraphfullscreen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadergraphfullscreen.d.ts","sourceRoot":"","sources":["../src/shadergraphfullscreen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,qBAAa,qBAAqB;WACZ,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE,GAChI;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,WAAW,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,IAAI,IAAI,CAAA;KAAE;CAe7F"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ShaderGraphPass } from './scenemanager';
|
|
2
|
+
export class ShaderGraphFullscreen {
|
|
3
|
+
static Create(scene, className, options) {
|
|
4
|
+
const opts = options || {};
|
|
5
|
+
const camera = opts.camera || scene.activeCamera;
|
|
6
|
+
const pp = ShaderGraphPass.CreatePostProcess(scene, camera, className, { injection: opts.injection || "afterPost", block: opts.block });
|
|
7
|
+
if (pp == null)
|
|
8
|
+
return null;
|
|
9
|
+
if (opts.injection === "beforePost") {
|
|
10
|
+
camera.detachPostProcess(pp);
|
|
11
|
+
camera.attachPostProcess(pp, 0);
|
|
12
|
+
}
|
|
13
|
+
const handle = {
|
|
14
|
+
pass: pp.__sgPass,
|
|
15
|
+
postProcess: pp,
|
|
16
|
+
get enabled() { return pp.enabled !== false; },
|
|
17
|
+
set enabled(value) { pp.enabled = value; },
|
|
18
|
+
dispose() { pp.dispose(camera); }
|
|
19
|
+
};
|
|
20
|
+
return handle;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CustomShaderMaterial } from './scenemanager';
|
|
2
|
+
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
|
|
3
|
+
export declare class ShaderGraphLightTable {
|
|
4
|
+
static readonly SLOTS: number;
|
|
5
|
+
static Bind(material: CustomShaderMaterial, mesh: AbstractMesh): void;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=shadergraphlighttable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadergraphlighttable.d.ts","sourceRoot":"","sources":["../src/shadergraphlighttable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AASnE,qBAAa,qBAAqB;IAC1B,gBAAuB,KAAK,EAAE,MAAM,CAAK;WAG3B,IAAI,CAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;CA0D/E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { LightingConversions } from './scenemanager';
|
|
2
|
+
import { Vector4 } from '@babylonjs/core/Maths/math.vector';
|
|
3
|
+
import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight';
|
|
4
|
+
import { SpotLight } from '@babylonjs/core/Lights/spotLight';
|
|
5
|
+
import { PointLight } from '@babylonjs/core/Lights/pointLight';
|
|
6
|
+
export class ShaderGraphLightTable {
|
|
7
|
+
static Bind(material, mesh) {
|
|
8
|
+
if (material == null)
|
|
9
|
+
return;
|
|
10
|
+
const scene = material.getScene();
|
|
11
|
+
let main = null;
|
|
12
|
+
if (scene != null) {
|
|
13
|
+
for (const light of scene.lights) {
|
|
14
|
+
if (light instanceof DirectionalLight && light.isEnabled()) {
|
|
15
|
+
main = light;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const info = material.getGraphInfo != null ? material.getGraphInfo() : null;
|
|
21
|
+
const destinationPi = (info != null && info.pipeline === "hdrp") ? 1 : Math.PI;
|
|
22
|
+
const lights = (mesh != null) ? (mesh.lightSources || []) : [];
|
|
23
|
+
let count = 0;
|
|
24
|
+
for (let i = 0; i < lights.length && count < ShaderGraphLightTable.SLOTS; i++) {
|
|
25
|
+
const light = lights[i];
|
|
26
|
+
if (light == null || light === main || !light.isEnabled())
|
|
27
|
+
continue;
|
|
28
|
+
let type = -1;
|
|
29
|
+
if (light instanceof SpotLight)
|
|
30
|
+
type = 2;
|
|
31
|
+
else if (light instanceof PointLight)
|
|
32
|
+
type = 1;
|
|
33
|
+
else if (light instanceof DirectionalLight)
|
|
34
|
+
type = 0;
|
|
35
|
+
if (type < 0)
|
|
36
|
+
continue;
|
|
37
|
+
const slot = String(count);
|
|
38
|
+
if (type === 0) {
|
|
39
|
+
const d = (light.transformedDirection != null ? light.transformedDirection : light.direction).clone().normalize();
|
|
40
|
+
material.setVector4Value("g_sgLight" + slot + "A", new Vector4(-d.x, -d.y, -d.z, 0));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const p = light.getAbsolutePosition();
|
|
44
|
+
material.setVector4Value("g_sgLight" + slot + "A", new Vector4(p.x, p.y, p.z, type));
|
|
45
|
+
}
|
|
46
|
+
const unity = LightingConversions.MainLightColor(light);
|
|
47
|
+
const diffuse = light.diffuse;
|
|
48
|
+
const peak = (diffuse != null) ? Math.max(diffuse.r, diffuse.g, diffuse.b) : 0;
|
|
49
|
+
const scale = (peak > 0) ? (Math.max(unity.r, unity.g, unity.b) / peak / destinationPi) : 0;
|
|
50
|
+
const linear = LightingConversions.UnityLinearLightColor(light);
|
|
51
|
+
const range = (typeof light.range === "number" && isFinite(light.range) && light.range > 0 && light.range < 1e30) ? light.range : 0;
|
|
52
|
+
material.setVector4Value("g_sgLight" + slot + "B", new Vector4(linear.r * scale, linear.g * scale, linear.b * scale, range > 0 ? 1 / (range * range) : 0));
|
|
53
|
+
if (type === 2) {
|
|
54
|
+
const s = (light.transformedDirection != null ? light.transformedDirection : light.direction).clone().normalize();
|
|
55
|
+
const cosOuter = Math.cos((light.angle != null ? light.angle : Math.PI / 2) / 2);
|
|
56
|
+
const inner = (typeof light.innerAngle === "number" && light.innerAngle > 0) ? Math.cos(light.innerAngle / 2) : cosOuter;
|
|
57
|
+
material.setVector4Value("g_sgLight" + slot + "C", new Vector4(-s.x, -s.y, -s.z, cosOuter));
|
|
58
|
+
material.setVector4Value("g_sgLight" + slot + "D", new Vector4(inner, 0, 0, 0));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
material.setVector4Value("g_sgLight" + slot + "C", new Vector4(0, 0, 0, -1));
|
|
62
|
+
material.setVector4Value("g_sgLight" + slot + "D", new Vector4(1, 0, 0, 0));
|
|
63
|
+
}
|
|
64
|
+
count++;
|
|
65
|
+
}
|
|
66
|
+
for (let i = count; i < ShaderGraphLightTable.SLOTS; i++) {
|
|
67
|
+
const slot = String(i);
|
|
68
|
+
material.setVector4Value("g_sgLight" + slot + "A", new Vector4(0, 0, 0, 0));
|
|
69
|
+
material.setVector4Value("g_sgLight" + slot + "B", new Vector4(0, 0, 0, 0));
|
|
70
|
+
}
|
|
71
|
+
material.setVector4Value("g_sgLightCount", new Vector4(count, 0, 0, 0));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
ShaderGraphLightTable.SLOTS = 8;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unityscrollbar.d.ts","sourceRoot":"","sources":["../src/unityscrollbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"unityscrollbar.d.ts","sourceRoot":"","sources":["../src/unityscrollbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAGzE,qBAAa,cAAe,SAAQ,SAAS;IACrC,OAAO,CAAC,UAAU,CAAyB;IAE3C,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,MAAM,EAGjC;IAED,SAAS,CAAC,iBAAiB,IAAI,MAAM;IAkBrB,SAAS,CAAC,mBAAmB,EAAE,GAAG;IAKlC,iBAAiB,CAAC,mBAAmB,EAAE,GAAG,EAAE,IAAI,EAAE,sBAAsB;CAM3F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs-toolkit/next",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.28.0",
|
|
4
4
|
"description": "Babylon Toolkit Runtime Library (ES6)",
|
|
5
5
|
"author": "MackeyK24 <mackeyk24@gmail.com>",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -160,23 +160,23 @@
|
|
|
160
160
|
"lib/**/*"
|
|
161
161
|
],
|
|
162
162
|
"devDependencies": {
|
|
163
|
-
"@babylonjs/core": "9.
|
|
164
|
-
"@babylonjs/gui": "9.
|
|
163
|
+
"@babylonjs/core": "9.28.0",
|
|
164
|
+
"@babylonjs/gui": "9.28.0",
|
|
165
165
|
"@babylonjs/havok": "^1.3.14",
|
|
166
|
-
"@babylonjs/addons": "9.
|
|
167
|
-
"@babylonjs/loaders": "9.
|
|
168
|
-
"@babylonjs/materials": "9.
|
|
169
|
-
"@babylonjs/inspector": "9.
|
|
166
|
+
"@babylonjs/addons": "9.28.0",
|
|
167
|
+
"@babylonjs/loaders": "9.28.0",
|
|
168
|
+
"@babylonjs/materials": "9.28.0",
|
|
169
|
+
"@babylonjs/inspector": "9.28.0",
|
|
170
170
|
"rimraf": "^6.0.1",
|
|
171
171
|
"typescript": "^6.0.3"
|
|
172
172
|
},
|
|
173
173
|
"peerDependencies": {
|
|
174
|
-
"@babylonjs/core": "9.
|
|
175
|
-
"@babylonjs/gui": "9.
|
|
174
|
+
"@babylonjs/core": "9.28.0",
|
|
175
|
+
"@babylonjs/gui": "9.28.0",
|
|
176
176
|
"@babylonjs/havok": "^1.3.14",
|
|
177
|
-
"@babylonjs/addons": "9.
|
|
178
|
-
"@babylonjs/loaders": "9.
|
|
179
|
-
"@babylonjs/materials": "9.
|
|
180
|
-
"@babylonjs/inspector": "9.
|
|
177
|
+
"@babylonjs/addons": "9.28.0",
|
|
178
|
+
"@babylonjs/loaders": "9.28.0",
|
|
179
|
+
"@babylonjs/materials": "9.28.0",
|
|
180
|
+
"@babylonjs/inspector": "9.28.0"
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IParticleSystemVector3 } from './scenemanager';
|
|
2
|
-
export interface IParticleSystemTransform {
|
|
3
|
-
name: string;
|
|
4
|
-
instanceId: number;
|
|
5
|
-
position: IParticleSystemVector3;
|
|
6
|
-
rotation: IParticleSystemVector3;
|
|
7
|
-
scale: IParticleSystemVector3;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=iparticlesystemtransform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iparticlesystemtransform.d.ts","sourceRoot":"","sources":["../src/iparticlesystemtransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,WAAW,wBAAwB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,QAAQ,EAAE,sBAAsB,CAAC;IACjC,KAAK,EAAE,sBAAsB,CAAC;CACjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/perlin2d.d.ts
DELETED
package/lib/perlin2d.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"perlin2d.d.ts","sourceRoot":"","sources":["../src/perlin2d.ts"],"names":[],"mappings":"AACA,qBAAa,QAAQ;IACf,OAAO,CAAC,IAAI,CAAW;gBACX,IAAI,EAAE,MAAM;IAsBxB,OAAO,CAAC,IAAI;IAGZ,OAAO,CAAC,IAAI;IAGZ,OAAO,CAAC,IAAI;IAUL,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;CAuB7C"}
|
package/lib/perlin2d.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export class Perlin2D {
|
|
2
|
-
constructor(seed) {
|
|
3
|
-
const p = new Array(256);
|
|
4
|
-
for (let i = 0; i < 256; i++)
|
|
5
|
-
p[i] = i;
|
|
6
|
-
let state = (seed | 0) >>> 0;
|
|
7
|
-
const nextRand = () => {
|
|
8
|
-
state = (state * 16807) % 2147483647;
|
|
9
|
-
return state / 2147483647;
|
|
10
|
-
};
|
|
11
|
-
for (let i = 255; i > 0; i--) {
|
|
12
|
-
const r = Math.floor(nextRand() * (i + 1));
|
|
13
|
-
const tmp = p[i];
|
|
14
|
-
p[i] = p[r];
|
|
15
|
-
p[r] = tmp;
|
|
16
|
-
}
|
|
17
|
-
this.perm = new Array(512);
|
|
18
|
-
for (let i = 0; i < 512; i++) {
|
|
19
|
-
this.perm[i] = p[i & 255];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
fade(t) {
|
|
23
|
-
return t * t * t * (t * (t * 6 - 15) + 10);
|
|
24
|
-
}
|
|
25
|
-
lerp(a, b, t) {
|
|
26
|
-
return a + t * (b - a);
|
|
27
|
-
}
|
|
28
|
-
grad(hash, x, y) {
|
|
29
|
-
const h = hash & 7;
|
|
30
|
-
const u = h < 4 ? x : y;
|
|
31
|
-
const v = h < 4 ? y : x;
|
|
32
|
-
return ((h & 1) ? -u : u) + ((h & 2) ? -v : v);
|
|
33
|
-
}
|
|
34
|
-
noise(x, y) {
|
|
35
|
-
const X = Math.floor(x) & 255;
|
|
36
|
-
const Y = Math.floor(y) & 255;
|
|
37
|
-
const xf = x - Math.floor(x);
|
|
38
|
-
const yf = y - Math.floor(y);
|
|
39
|
-
const u = this.fade(xf);
|
|
40
|
-
const v = this.fade(yf);
|
|
41
|
-
const A = this.perm[X] + Y;
|
|
42
|
-
const B = this.perm[X + 1] + Y;
|
|
43
|
-
return this.lerp(this.lerp(this.grad(this.perm[A], xf, yf), this.grad(this.perm[B], xf - 1, yf), u), this.lerp(this.grad(this.perm[A + 1], xf, yf - 1), this.grad(this.perm[B + 1], xf - 1, yf - 1), u), v);
|
|
44
|
-
}
|
|
45
|
-
}
|