vanta-engine 1.0.3 → 1.0.4
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/dist/{chunk-AAWFTQHP.js → chunk-BDKR3WGZ.mjs} +1 -1
- package/dist/index.js +177 -139
- package/dist/index.js.map +1 -1
- package/dist/{index.cjs → index.mjs} +140 -178
- package/dist/index.mjs.map +1 -0
- package/dist/{module-A2C3IOOM.js → module-62JUDQR5.mjs} +2 -2
- package/package.json +9 -7
- package/dist/index.cjs.map +0 -1
- /package/dist/{chunk-AAWFTQHP.js.map → chunk-BDKR3WGZ.mjs.map} +0 -0
- /package/dist/{module-A2C3IOOM.js.map → module-62JUDQR5.mjs.map} +0 -0
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__toESM
|
|
4
|
+
} from "./chunk-BDKR3WGZ.mjs";
|
|
32
5
|
|
|
33
6
|
// (disabled):url
|
|
34
7
|
var require_url = __commonJS({
|
|
@@ -37,19 +10,12 @@ var require_url = __commonJS({
|
|
|
37
10
|
}
|
|
38
11
|
});
|
|
39
12
|
|
|
40
|
-
// (disabled):module
|
|
41
|
-
var require_module = __commonJS({
|
|
42
|
-
"(disabled):module"() {
|
|
43
|
-
"use strict";
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
13
|
// node_modules/wasmoon/dist/index.js
|
|
48
14
|
var require_dist = __commonJS({
|
|
49
|
-
"node_modules/wasmoon/dist/index.js"(exports,
|
|
15
|
+
"node_modules/wasmoon/dist/index.js"(exports, module) {
|
|
50
16
|
"use strict";
|
|
51
17
|
(function(global, factory) {
|
|
52
|
-
typeof exports === "object" && typeof
|
|
18
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.wasmoon = {}));
|
|
53
19
|
})(exports, (function(exports2) {
|
|
54
20
|
"use strict";
|
|
55
21
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
@@ -1266,7 +1232,7 @@ ${traceback}`;
|
|
|
1266
1232
|
var la = process.versions.node, ma = la.split(".").slice(0, 3);
|
|
1267
1233
|
ma = 1e4 * ma[0] + 100 * ma[1] + 1 * ma[2].split("-")[0];
|
|
1268
1234
|
if (16e4 > ma) throw Error("This emscripten-generated code requires node v16.0.0 (detected v" + la + ")");
|
|
1269
|
-
const { createRequire: a } = await
|
|
1235
|
+
const { createRequire: a } = await import("./module-62JUDQR5.mjs");
|
|
1270
1236
|
var require$1 = a(typeof document === "undefined" && typeof location === "undefined" ? require_url().pathToFileURL(__filename).href : typeof document === "undefined" ? location.href : _documentCurrentScript && _documentCurrentScript.src || new URL("index.js", document.baseURI).href), fs = require$1("fs"), na = require$1("path");
|
|
1271
1237
|
k ? r = na.dirname(r) + "/" : r = require$1("url").fileURLToPath(new URL("./", typeof document === "undefined" && typeof location === "undefined" ? require_url().pathToFileURL(__filename).href : typeof document === "undefined" ? location.href : _documentCurrentScript && _documentCurrentScript.src || new URL("index.js", document.baseURI).href));
|
|
1272
1238
|
ia = (b, c) => {
|
|
@@ -4027,7 +3993,7 @@ ${traceback}`;
|
|
|
4027
3993
|
})();
|
|
4028
3994
|
class LuaWasm {
|
|
4029
3995
|
static async initialize(customWasmFileLocation, environmentVariables) {
|
|
4030
|
-
const
|
|
3996
|
+
const module2 = await initWasmModule({
|
|
4031
3997
|
locateFile: (path, scriptDirectory) => {
|
|
4032
3998
|
return customWasmFileLocation || scriptDirectory + path;
|
|
4033
3999
|
},
|
|
@@ -4037,13 +4003,13 @@ ${traceback}`;
|
|
|
4037
4003
|
}
|
|
4038
4004
|
}
|
|
4039
4005
|
});
|
|
4040
|
-
return new LuaWasm(
|
|
4006
|
+
return new LuaWasm(module2);
|
|
4041
4007
|
}
|
|
4042
|
-
constructor(
|
|
4008
|
+
constructor(module2) {
|
|
4043
4009
|
this.referenceTracker = /* @__PURE__ */ new WeakMap();
|
|
4044
4010
|
this.referenceMap = /* @__PURE__ */ new Map();
|
|
4045
4011
|
this.availableReferences = [];
|
|
4046
|
-
this.module =
|
|
4012
|
+
this.module = module2;
|
|
4047
4013
|
this.luaL_checkversion_ = this.cwrap("luaL_checkversion_", null, ["number", "number", "number"]);
|
|
4048
4014
|
this.luaL_getmetafield = this.cwrap("luaL_getmetafield", "number", ["number", "number", "string"]);
|
|
4049
4015
|
this.luaL_callmeta = this.cwrap("luaL_callmeta", "number", ["number", "number", "string"]);
|
|
@@ -4355,54 +4321,8 @@ ${traceback}`;
|
|
|
4355
4321
|
}
|
|
4356
4322
|
});
|
|
4357
4323
|
|
|
4358
|
-
// src/index.ts
|
|
4359
|
-
var index_exports = {};
|
|
4360
|
-
__export(index_exports, {
|
|
4361
|
-
AssetFile: () => AssetFile,
|
|
4362
|
-
AttachmentType: () => AttachmentType,
|
|
4363
|
-
Camera3D: () => Camera3D,
|
|
4364
|
-
CubeMapTexture: () => CubeMapTexture,
|
|
4365
|
-
DirectionalLight: () => DirectionalLight,
|
|
4366
|
-
DrawFlag: () => DrawFlag,
|
|
4367
|
-
Framebuffer: () => Framebuffer,
|
|
4368
|
-
GraphicsManager: () => GraphicsManager,
|
|
4369
|
-
HookManager: () => HookManager,
|
|
4370
|
-
InputManager: () => InputManager,
|
|
4371
|
-
Light: () => Light,
|
|
4372
|
-
Material: () => Material,
|
|
4373
|
-
Mesh: () => Mesh,
|
|
4374
|
-
Model: () => Model,
|
|
4375
|
-
MouseButton: () => MouseButton,
|
|
4376
|
-
Node: () => Node,
|
|
4377
|
-
Node2D: () => Node2D,
|
|
4378
|
-
Node3D: () => Node3D,
|
|
4379
|
-
Object3D: () => Object3D,
|
|
4380
|
-
PointLight: () => PointLight,
|
|
4381
|
-
Scene: () => Scene,
|
|
4382
|
-
ShaderProgram: () => ShaderProgram,
|
|
4383
|
-
Skybox: () => Skybox,
|
|
4384
|
-
SpotLight: () => SpotLight,
|
|
4385
|
-
Sprite2D: () => Sprite2D,
|
|
4386
|
-
Texture: () => Texture,
|
|
4387
|
-
TextureType: () => TextureType,
|
|
4388
|
-
WebGLUniformType: () => WebGLUniformType,
|
|
4389
|
-
basename_path: () => basename_path,
|
|
4390
|
-
default: () => index_default,
|
|
4391
|
-
degrees_to_radians: () => degrees_to_radians,
|
|
4392
|
-
dirname_path: () => dirname_path,
|
|
4393
|
-
get_skybox_vao: () => get_skybox_vao,
|
|
4394
|
-
get_sprite_vao: () => get_sprite_vao,
|
|
4395
|
-
get_uniform_label_index: () => get_uniform_label_index,
|
|
4396
|
-
has_flag: () => has_flag,
|
|
4397
|
-
join_path: () => join_path,
|
|
4398
|
-
load_obj: () => load_obj,
|
|
4399
|
-
normalize_uniform_label: () => normalize_uniform_label,
|
|
4400
|
-
parse_path: () => parse_path
|
|
4401
|
-
});
|
|
4402
|
-
module.exports = __toCommonJS(index_exports);
|
|
4403
|
-
|
|
4404
4324
|
// src/graphics/assets/asset_loaders/obj.ts
|
|
4405
|
-
|
|
4325
|
+
import { Vec3 as Vec32 } from "@vicimpa/glm";
|
|
4406
4326
|
|
|
4407
4327
|
// src/graphics/assets/texture.ts
|
|
4408
4328
|
var UNSIGNED_BYTE = 5121;
|
|
@@ -5117,7 +5037,7 @@ var Mesh = class {
|
|
|
5117
5037
|
};
|
|
5118
5038
|
|
|
5119
5039
|
// src/node.ts
|
|
5120
|
-
|
|
5040
|
+
import { Vec3, Vec2, Mat4, Quat } from "@vicimpa/glm";
|
|
5121
5041
|
var Node = class _Node {
|
|
5122
5042
|
constructor(engine, name) {
|
|
5123
5043
|
this.parent = null;
|
|
@@ -5285,9 +5205,9 @@ var Node2D = class _Node2D extends Node {
|
|
|
5285
5205
|
super(engine, name);
|
|
5286
5206
|
this.proxy_on_change_position = this.proxy_on_change_position.bind(this);
|
|
5287
5207
|
this.proxy_on_change_scale = this.proxy_on_change_scale.bind(this);
|
|
5288
|
-
this.stored_position = new Proxy(new
|
|
5208
|
+
this.stored_position = new Proxy(new Vec2(0), { set: this.proxy_on_change_position });
|
|
5289
5209
|
this.stored_rotation = 0;
|
|
5290
|
-
this.stored_scale = new Proxy(new
|
|
5210
|
+
this.stored_scale = new Proxy(new Vec2(1), { set: this.proxy_on_change_scale });
|
|
5291
5211
|
}
|
|
5292
5212
|
get position() {
|
|
5293
5213
|
return this.stored_position;
|
|
@@ -5330,10 +5250,10 @@ var Node2D = class _Node2D extends Node {
|
|
|
5330
5250
|
}
|
|
5331
5251
|
// ABSTRACT METHOD
|
|
5332
5252
|
get_model_matrix() {
|
|
5333
|
-
let model = new
|
|
5334
|
-
model.translate(new
|
|
5335
|
-
model.rotate(this.rotation, new
|
|
5336
|
-
model.scale(new
|
|
5253
|
+
let model = new Mat4().identity();
|
|
5254
|
+
model.translate(new Vec3(this.position.x, this.position.y, 0));
|
|
5255
|
+
model.rotate(this.rotation, new Vec3(0, 0, 1));
|
|
5256
|
+
model.scale(new Vec3(this.scale.x, this.scale.y, 1));
|
|
5337
5257
|
return model;
|
|
5338
5258
|
}
|
|
5339
5259
|
get_world_matrix() {
|
|
@@ -5350,9 +5270,9 @@ var Node3D = class _Node3D extends Node {
|
|
|
5350
5270
|
this.proxy_on_change_position = this.proxy_on_change_position.bind(this);
|
|
5351
5271
|
this.proxy_on_change_rotation = this.proxy_on_change_rotation.bind(this);
|
|
5352
5272
|
this.proxy_on_change_scale = this.proxy_on_change_scale.bind(this);
|
|
5353
|
-
this.stored_position = new Proxy(new
|
|
5354
|
-
this.stored_rotation = new Proxy(new
|
|
5355
|
-
this.stored_scale = new Proxy(new
|
|
5273
|
+
this.stored_position = new Proxy(new Vec3(0), { set: this.proxy_on_change_position });
|
|
5274
|
+
this.stored_rotation = new Proxy(new Quat(), { set: this.proxy_on_change_rotation });
|
|
5275
|
+
this.stored_scale = new Proxy(new Vec3(1), { set: this.proxy_on_change_scale });
|
|
5356
5276
|
}
|
|
5357
5277
|
get position() {
|
|
5358
5278
|
return this.stored_position;
|
|
@@ -5401,7 +5321,7 @@ var Node3D = class _Node3D extends Node {
|
|
|
5401
5321
|
// ABSTRACT METHOD
|
|
5402
5322
|
get_world_position() {
|
|
5403
5323
|
const world_matrix = this.get_world_matrix();
|
|
5404
|
-
return new
|
|
5324
|
+
return new Vec3(world_matrix[12], world_matrix[13], world_matrix[14]);
|
|
5405
5325
|
}
|
|
5406
5326
|
get_parent_world_matrix() {
|
|
5407
5327
|
if (this.parent instanceof _Node3D) {
|
|
@@ -5415,12 +5335,12 @@ var Node3D = class _Node3D extends Node {
|
|
|
5415
5335
|
parent = parent.parent;
|
|
5416
5336
|
}
|
|
5417
5337
|
}
|
|
5418
|
-
return new
|
|
5338
|
+
return new Mat4().identity();
|
|
5419
5339
|
}
|
|
5420
5340
|
get_model_matrix() {
|
|
5421
|
-
const model = new
|
|
5341
|
+
const model = new Mat4().identity();
|
|
5422
5342
|
model.translate(this.position);
|
|
5423
|
-
const rotation_mat = new
|
|
5343
|
+
const rotation_mat = new Mat4().fromQuat(this.rotation);
|
|
5424
5344
|
model.mul(rotation_mat);
|
|
5425
5345
|
model.scale(this.scale);
|
|
5426
5346
|
return model;
|
|
@@ -5431,7 +5351,7 @@ var Node3D = class _Node3D extends Node {
|
|
|
5431
5351
|
};
|
|
5432
5352
|
|
|
5433
5353
|
// src/node/object3d.ts
|
|
5434
|
-
|
|
5354
|
+
import { Vec2 as Vec22, Vec4 as Vec42 } from "@vicimpa/glm";
|
|
5435
5355
|
|
|
5436
5356
|
// src/graphics/assets/vaos.ts
|
|
5437
5357
|
var skybox_VAO = null;
|
|
@@ -5683,7 +5603,7 @@ var Object3D = class extends Node3D {
|
|
|
5683
5603
|
);
|
|
5684
5604
|
var mesh_size = this.model.mesh.dimensions.clone().mul(this.scale).length();
|
|
5685
5605
|
var local_mesh_center = this.model.mesh.center;
|
|
5686
|
-
var mesh_center = new
|
|
5606
|
+
var mesh_center = new Vec42(local_mesh_center.x, local_mesh_center.y, local_mesh_center.z, 1).applyMat4(this.get_world_matrix());
|
|
5687
5607
|
for (var i = 0; i < n; ++i) {
|
|
5688
5608
|
if (i < point_lights_count) {
|
|
5689
5609
|
const light = point_lights[i];
|
|
@@ -5700,7 +5620,7 @@ var Object3D = class extends Node3D {
|
|
|
5700
5620
|
gm.set_uniform("directional_lights_count", directional_lights_count);
|
|
5701
5621
|
gm.set_uniform("directional_light_shadow_maps", gm.directional_light_shadow_map_texture);
|
|
5702
5622
|
gm.set_uniform("point_light_shadow_maps", gm.point_light_shadow_map_texture);
|
|
5703
|
-
gm.set_uniform("shadow_map_size", new
|
|
5623
|
+
gm.set_uniform("shadow_map_size", new Vec22(gm.shadow_resolution));
|
|
5704
5624
|
gm.set_uniform("u_model", this.get_world_matrix());
|
|
5705
5625
|
gm.set_uniform("u_view", view_matrix);
|
|
5706
5626
|
gm.set_uniform("u_projection", projection_matrix_3d);
|
|
@@ -5765,7 +5685,7 @@ var AssetFile;
|
|
|
5765
5685
|
get_fallback(
|
|
5766
5686
|
material_data.diffuse_texture?.name ? image_assets.get(material_data.diffuse_texture?.name) : void 0,
|
|
5767
5687
|
material_data.diffuse_color,
|
|
5768
|
-
new
|
|
5688
|
+
new Vec32(1)
|
|
5769
5689
|
),
|
|
5770
5690
|
get_fallback(
|
|
5771
5691
|
material_data.metalic_texture?.name ? image_assets.get(material_data.metalic_texture?.name) : void 0,
|
|
@@ -5813,7 +5733,7 @@ var AssetFile;
|
|
|
5813
5733
|
throw new Error(`Failed to find the material named "${object_data.material}" associated with the object named "${object_data.name}" in the .obj file at "${obj_path}" when attempting to load the obj model.`);
|
|
5814
5734
|
}
|
|
5815
5735
|
} else {
|
|
5816
|
-
material = new Material(engine.graphics_manager, "default", new
|
|
5736
|
+
material = new Material(engine.graphics_manager, "default", new Vec32(0), 0, 0, 0, null, engine.graphics_manager.default_3d_shader_program);
|
|
5817
5737
|
}
|
|
5818
5738
|
var model = new Model(engine.graphics_manager, "default", mesh, material);
|
|
5819
5739
|
object = new Object3D(engine, object_data.name, model);
|
|
@@ -5830,7 +5750,7 @@ var AssetFile;
|
|
|
5830
5750
|
throw new Error(`Failed to find the material named "${group_data.material}" associated with the group named "${group_data.name}" object named "${object_data.name}" in the .obj file at "${obj_path}" when attempting to load the obj model.`);
|
|
5831
5751
|
}
|
|
5832
5752
|
} else {
|
|
5833
|
-
material = new Material(engine.graphics_manager, "default", new
|
|
5753
|
+
material = new Material(engine.graphics_manager, "default", new Vec32(0), 0, 0, 0, null, engine.graphics_manager.default_3d_shader_program);
|
|
5834
5754
|
}
|
|
5835
5755
|
var model = new Model(engine.graphics_manager, "default", mesh, material);
|
|
5836
5756
|
object.push_child(new Object3D(engine, group_data.name, model));
|
|
@@ -5878,8 +5798,8 @@ var AssetFile;
|
|
|
5878
5798
|
normals: new Float32Array([]),
|
|
5879
5799
|
uvs: new Float32Array([]),
|
|
5880
5800
|
indices: new Uint16Array([]),
|
|
5881
|
-
dimensions: new
|
|
5882
|
-
center: new
|
|
5801
|
+
dimensions: new Vec32(0),
|
|
5802
|
+
center: new Vec32(0)
|
|
5883
5803
|
};
|
|
5884
5804
|
}
|
|
5885
5805
|
static create_material(name) {
|
|
@@ -5914,19 +5834,19 @@ var AssetFile;
|
|
|
5914
5834
|
case "kd":
|
|
5915
5835
|
if (current_material) {
|
|
5916
5836
|
const [r, g, b] = parts.slice(1).map(Number);
|
|
5917
|
-
current_material.diffuse_color = new
|
|
5837
|
+
current_material.diffuse_color = new Vec32(r, g, b);
|
|
5918
5838
|
}
|
|
5919
5839
|
break;
|
|
5920
5840
|
case "ka":
|
|
5921
5841
|
if (current_material) {
|
|
5922
5842
|
const [r, g, b] = parts.slice(1).map(Number);
|
|
5923
|
-
current_material.ambient_color = new
|
|
5843
|
+
current_material.ambient_color = new Vec32(r, g, b);
|
|
5924
5844
|
}
|
|
5925
5845
|
break;
|
|
5926
5846
|
case "ks":
|
|
5927
5847
|
if (current_material) {
|
|
5928
5848
|
const [r, g, b] = parts.slice(1).map(Number);
|
|
5929
|
-
current_material.specular_color = new
|
|
5849
|
+
current_material.specular_color = new Vec32(r, g, b);
|
|
5930
5850
|
}
|
|
5931
5851
|
break;
|
|
5932
5852
|
case "ns":
|
|
@@ -5999,7 +5919,7 @@ var AssetFile;
|
|
|
5999
5919
|
y = Number(parts[3]);
|
|
6000
5920
|
if (parts.length >= 5)
|
|
6001
5921
|
z = Number(parts[4]);
|
|
6002
|
-
current_material.transmission_filter_color = new
|
|
5922
|
+
current_material.transmission_filter_color = new Vec32(
|
|
6003
5923
|
x,
|
|
6004
5924
|
y !== null ? y : x,
|
|
6005
5925
|
z !== null ? z : x
|
|
@@ -6007,7 +5927,7 @@ var AssetFile;
|
|
|
6007
5927
|
current_material.transmission_filter_xyz;
|
|
6008
5928
|
} else {
|
|
6009
5929
|
const [r, g, b] = parts.slice(1).map(Number);
|
|
6010
|
-
current_material.transmission_filter_color = new
|
|
5930
|
+
current_material.transmission_filter_color = new Vec32(r, g, b);
|
|
6011
5931
|
}
|
|
6012
5932
|
}
|
|
6013
5933
|
break;
|
|
@@ -6126,7 +6046,7 @@ var AssetFile;
|
|
|
6126
6046
|
v = Number(current_flag_arguments[1]);
|
|
6127
6047
|
if (current_flag_arguments.length >= 3)
|
|
6128
6048
|
w = Number(current_flag_arguments[2]);
|
|
6129
|
-
texture_data.offset = new
|
|
6049
|
+
texture_data.offset = new Vec32(u, v, w);
|
|
6130
6050
|
break;
|
|
6131
6051
|
case "-s":
|
|
6132
6052
|
var u = Number(current_flag_arguments[0]);
|
|
@@ -6136,7 +6056,7 @@ var AssetFile;
|
|
|
6136
6056
|
v = Number(current_flag_arguments[1]);
|
|
6137
6057
|
if (current_flag_arguments.length >= 3)
|
|
6138
6058
|
w = Number(current_flag_arguments[2]);
|
|
6139
|
-
texture_data.scale = new
|
|
6059
|
+
texture_data.scale = new Vec32(u, v, w);
|
|
6140
6060
|
break;
|
|
6141
6061
|
case "-t":
|
|
6142
6062
|
var u = Number(current_flag_arguments[0]);
|
|
@@ -6146,7 +6066,7 @@ var AssetFile;
|
|
|
6146
6066
|
v = Number(current_flag_arguments[1]);
|
|
6147
6067
|
if (current_flag_arguments.length >= 3)
|
|
6148
6068
|
w = Number(current_flag_arguments[2]);
|
|
6149
|
-
texture_data.turbulence = new
|
|
6069
|
+
texture_data.turbulence = new Vec32(u, v, w);
|
|
6150
6070
|
break;
|
|
6151
6071
|
case "-texres":
|
|
6152
6072
|
texture_data.generated_texture_resolution = Number(current_flag_arguments[0]);
|
|
@@ -6210,8 +6130,8 @@ var AssetFile;
|
|
|
6210
6130
|
current_data.vertices = new Float32Array(current_data.temp.vertices_final);
|
|
6211
6131
|
current_data.uvs = new Float32Array(current_data.temp.uvs_final);
|
|
6212
6132
|
current_data.normals = new Float32Array(current_data.temp.normals_final);
|
|
6213
|
-
current_data.dimensions = new
|
|
6214
|
-
current_data.center = new
|
|
6133
|
+
current_data.dimensions = new Vec32(current_data.temp.max_x - current_data.temp.min_x, current_data.temp.max_y - current_data.temp.min_y, current_data.temp.max_z - current_data.temp.min_z);
|
|
6134
|
+
current_data.center = new Vec32((current_data.temp.max_x + current_data.temp.min_x) / 2, (current_data.temp.max_y + current_data.temp.min_y) / 2, (current_data.temp.max_z + current_data.temp.min_z) / 2);
|
|
6215
6135
|
if (collection_type === 0 /* OBJECT */) {
|
|
6216
6136
|
current_object.data = current_data;
|
|
6217
6137
|
} else if (current_group) {
|
|
@@ -6404,8 +6324,8 @@ async function parse_obj(text) {
|
|
|
6404
6324
|
normals: new Float32Array(normals),
|
|
6405
6325
|
uvs: new Float32Array(uvs),
|
|
6406
6326
|
indices: new Uint16Array(indices),
|
|
6407
|
-
dimensions: new
|
|
6408
|
-
center: new
|
|
6327
|
+
dimensions: new Vec32(max_x - min_x, max_y - min_y, max_z - min_z),
|
|
6328
|
+
center: new Vec32((max_x + min_x) / 2, (max_y + min_y) / 2, (max_z + min_z) / 2)
|
|
6409
6329
|
};
|
|
6410
6330
|
}
|
|
6411
6331
|
async function load_obj(gm, model_path, image_asset_paths) {
|
|
@@ -6434,7 +6354,7 @@ async function load_obj(gm, model_path, image_asset_paths) {
|
|
|
6434
6354
|
}
|
|
6435
6355
|
|
|
6436
6356
|
// src/graphics/framebuffer.ts
|
|
6437
|
-
|
|
6357
|
+
import { Vec4 as Vec43 } from "@vicimpa/glm";
|
|
6438
6358
|
var AttachmentType = /* @__PURE__ */ ((AttachmentType2) => {
|
|
6439
6359
|
AttachmentType2["TEXTURE_COLOR"] = "TEXTURE_COLOR";
|
|
6440
6360
|
AttachmentType2["TEXTURE_DEPTH"] = "TEXTURE_DEPTH";
|
|
@@ -6470,7 +6390,7 @@ function has_flag(bit_flag, flag) {
|
|
|
6470
6390
|
return (bit_flag & flag) === flag;
|
|
6471
6391
|
}
|
|
6472
6392
|
var Framebuffer = class {
|
|
6473
|
-
constructor(name, gm, gl, attachment_infos, draw_flags, clear_color = new
|
|
6393
|
+
constructor(name, gm, gl, attachment_infos, draw_flags, clear_color = new Vec43(0, 0, 0, 1), read_from_back_buffer = false) {
|
|
6474
6394
|
this.width = 0;
|
|
6475
6395
|
this.height = 0;
|
|
6476
6396
|
this.attachment_info_map = {};
|
|
@@ -6763,7 +6683,7 @@ var Framebuffer = class {
|
|
|
6763
6683
|
};
|
|
6764
6684
|
|
|
6765
6685
|
// src/graphics/graphics_manager.ts
|
|
6766
|
-
|
|
6686
|
+
import { Mat4 as Mat43 } from "@vicimpa/glm";
|
|
6767
6687
|
|
|
6768
6688
|
// src/shaders/default_2d.vs.ts
|
|
6769
6689
|
var default_2d_vs_default = `#version 300 es
|
|
@@ -7605,7 +7525,7 @@ var GraphicsManager = class _GraphicsManager {
|
|
|
7605
7525
|
this.engine.on_global_update_callback(this.engine, current_time, delta_time);
|
|
7606
7526
|
this.engine.main_scene.update(current_time, delta_time);
|
|
7607
7527
|
this.engine.input_manager.update();
|
|
7608
|
-
const ortho_projection = new
|
|
7528
|
+
const ortho_projection = new Mat43().orthoZO(0, this.canvas.width, 0, this.canvas.height, -1, 1);
|
|
7609
7529
|
if (this.engine.main_scene.main_camera_3d) {
|
|
7610
7530
|
const view_matrix = this.engine.main_scene.main_camera_3d.get_view_matrix();
|
|
7611
7531
|
const projection_matrix = this.engine.main_scene.main_camera_3d.get_projection_matrix(this.canvas);
|
|
@@ -7740,7 +7660,7 @@ var GraphicsManager = class _GraphicsManager {
|
|
|
7740
7660
|
};
|
|
7741
7661
|
|
|
7742
7662
|
// src/node/camera3d.ts
|
|
7743
|
-
|
|
7663
|
+
import { Mat4 as Mat44 } from "@vicimpa/glm";
|
|
7744
7664
|
var Camera3D = class extends Node3D {
|
|
7745
7665
|
constructor() {
|
|
7746
7666
|
super(...arguments);
|
|
@@ -7750,7 +7670,7 @@ var Camera3D = class extends Node3D {
|
|
|
7750
7670
|
}
|
|
7751
7671
|
get_projection_matrix(canvas) {
|
|
7752
7672
|
const aspect = canvas.width / canvas.height;
|
|
7753
|
-
return new
|
|
7673
|
+
return new Mat44().perspectiveNO(
|
|
7754
7674
|
this.fov,
|
|
7755
7675
|
aspect,
|
|
7756
7676
|
this.near_plane,
|
|
@@ -7758,9 +7678,9 @@ var Camera3D = class extends Node3D {
|
|
|
7758
7678
|
);
|
|
7759
7679
|
}
|
|
7760
7680
|
get_view_matrix() {
|
|
7761
|
-
const view = new
|
|
7681
|
+
const view = new Mat44().identity();
|
|
7762
7682
|
const invRot = this.rotation.clone().invert();
|
|
7763
|
-
view.mul(new
|
|
7683
|
+
view.mul(new Mat44().fromQuat(invRot));
|
|
7764
7684
|
view.translate(this.position.clone().negate());
|
|
7765
7685
|
return view;
|
|
7766
7686
|
}
|
|
@@ -7792,33 +7712,33 @@ var Light = class extends Node3D {
|
|
|
7792
7712
|
};
|
|
7793
7713
|
|
|
7794
7714
|
// src/node/lights/point_light.ts
|
|
7795
|
-
|
|
7715
|
+
import { Mat4 as Mat45, Vec3 as Vec34 } from "@vicimpa/glm";
|
|
7796
7716
|
var point_light_shadow_lookat_values = [
|
|
7797
|
-
[new
|
|
7717
|
+
[new Vec34(1, 0, 0), new Vec34(0, 1, 0)],
|
|
7798
7718
|
// +X: Up is -Y
|
|
7799
|
-
[new
|
|
7719
|
+
[new Vec34(-1, 0, 0), new Vec34(0, 1, 0)],
|
|
7800
7720
|
// -X: Up is -Y
|
|
7801
|
-
[new
|
|
7721
|
+
[new Vec34(0, 1, 0), new Vec34(0, 0, 1)],
|
|
7802
7722
|
// +Y: Up is +Z
|
|
7803
|
-
[new
|
|
7723
|
+
[new Vec34(0, -1, 0), new Vec34(0, 0, -1)],
|
|
7804
7724
|
// -Y: Up is -Z
|
|
7805
|
-
[new
|
|
7725
|
+
[new Vec34(0, 0, 1), new Vec34(0, 1, 0)],
|
|
7806
7726
|
// +Z: Up is -Y
|
|
7807
|
-
[new
|
|
7727
|
+
[new Vec34(0, 0, -1), new Vec34(0, 1, 0)]
|
|
7808
7728
|
// -Z: Up is -Y
|
|
7809
7729
|
];
|
|
7810
7730
|
var PointLight = class extends Light {
|
|
7811
7731
|
constructor(engine, name, color, ambient, diffuse, specular, energy, range, shader_program = null) {
|
|
7812
7732
|
super(engine, name, color, ambient, diffuse, specular, energy);
|
|
7813
|
-
this.shadow_projection = new
|
|
7814
|
-
this.parent_world_matrix = new
|
|
7733
|
+
this.shadow_projection = new Mat45();
|
|
7734
|
+
this.parent_world_matrix = new Mat45();
|
|
7815
7735
|
this.point_light_space_matrices = [
|
|
7816
|
-
new
|
|
7817
|
-
new
|
|
7818
|
-
new
|
|
7819
|
-
new
|
|
7820
|
-
new
|
|
7821
|
-
new
|
|
7736
|
+
new Mat45(),
|
|
7737
|
+
new Mat45(),
|
|
7738
|
+
new Mat45(),
|
|
7739
|
+
new Mat45(),
|
|
7740
|
+
new Mat45(),
|
|
7741
|
+
new Mat45()
|
|
7822
7742
|
];
|
|
7823
7743
|
this.ambient = ambient;
|
|
7824
7744
|
this.diffuse = diffuse;
|
|
@@ -7841,7 +7761,7 @@ var PointLight = class extends Light {
|
|
|
7841
7761
|
for (let i = 0; i < 6; ++i) {
|
|
7842
7762
|
const [center_offset, up] = point_light_shadow_lookat_values[i];
|
|
7843
7763
|
const offset_position = get_world_position.clone().add(center_offset);
|
|
7844
|
-
const view = new
|
|
7764
|
+
const view = new Mat45().lookAt(
|
|
7845
7765
|
get_world_position,
|
|
7846
7766
|
offset_position,
|
|
7847
7767
|
up
|
|
@@ -7850,7 +7770,7 @@ var PointLight = class extends Light {
|
|
|
7850
7770
|
}
|
|
7851
7771
|
}
|
|
7852
7772
|
on_change_range(value) {
|
|
7853
|
-
this.shadow_projection = new
|
|
7773
|
+
this.shadow_projection = new Mat45().perspectiveZO(90 * Math.PI / 180, 1, 0.1, value);
|
|
7854
7774
|
this.update_lsms();
|
|
7855
7775
|
}
|
|
7856
7776
|
on_change_position(new_value) {
|
|
@@ -7911,11 +7831,11 @@ var PointLight = class extends Light {
|
|
|
7911
7831
|
};
|
|
7912
7832
|
|
|
7913
7833
|
// src/node/lights/directional_light.ts
|
|
7914
|
-
|
|
7834
|
+
import { Mat3 as Mat32, Mat4 as Mat46, Quat as Quat3, Vec3 as Vec35, Vec4 as Vec46 } from "@vicimpa/glm";
|
|
7915
7835
|
var DirectionalLight = class extends Light {
|
|
7916
7836
|
constructor(engine, name, color, ambient, diffuse, specular, energy, shader_program = null) {
|
|
7917
7837
|
super(engine, name, color, ambient, diffuse, specular, energy);
|
|
7918
|
-
this.directional_light_space_matrix = new
|
|
7838
|
+
this.directional_light_space_matrix = new Mat46();
|
|
7919
7839
|
this.ambient = ambient;
|
|
7920
7840
|
this.diffuse = diffuse;
|
|
7921
7841
|
this.specular = specular;
|
|
@@ -7934,7 +7854,7 @@ var DirectionalLight = class extends Light {
|
|
|
7934
7854
|
this.engine.main_scene.main_camera_3d.get_projection_matrix(this.engine.canvas),
|
|
7935
7855
|
this.engine.main_scene.main_camera_3d.get_view_matrix()
|
|
7936
7856
|
);
|
|
7937
|
-
const light_dir = new
|
|
7857
|
+
const light_dir = new Vec46(1, 0, 0, 1).applyQuat(this.rotation).xyz;
|
|
7938
7858
|
this.directional_light_space_matrix = this.get_light_space_matrix(
|
|
7939
7859
|
light_dir,
|
|
7940
7860
|
corners
|
|
@@ -7957,9 +7877,9 @@ var DirectionalLight = class extends Light {
|
|
|
7957
7877
|
set_uniforms(array_name, index) {
|
|
7958
7878
|
if (this.engine.main_scene.main_camera_3d) {
|
|
7959
7879
|
const world_matrix = this.get_world_matrix();
|
|
7960
|
-
const world_mat3 = new
|
|
7961
|
-
const world_rotation = new
|
|
7962
|
-
const world_rotation_matrix = new
|
|
7880
|
+
const world_mat3 = new Mat32().fromMat4(world_matrix);
|
|
7881
|
+
const world_rotation = new Quat3().fromMat3(world_mat3).normalize();
|
|
7882
|
+
const world_rotation_matrix = new Mat46().fromQuat(world_rotation);
|
|
7963
7883
|
this.engine.graphics_manager.set_uniform(`${array_name}[${index}].rotation`, world_rotation_matrix);
|
|
7964
7884
|
this.engine.graphics_manager.set_uniform(`u_directional_light_space_matrix[${index}]`, this.directional_light_space_matrix);
|
|
7965
7885
|
super.set_uniforms(array_name, index);
|
|
@@ -7984,7 +7904,7 @@ var DirectionalLight = class extends Light {
|
|
|
7984
7904
|
for (var x = 0; x < 2; ++x) {
|
|
7985
7905
|
for (var y = 0; y < 2; ++y) {
|
|
7986
7906
|
for (var z = 0; z < 2; ++z) {
|
|
7987
|
-
const pt = new
|
|
7907
|
+
const pt = new Vec46(
|
|
7988
7908
|
2 * x - 1,
|
|
7989
7909
|
2 * y - 1,
|
|
7990
7910
|
2 * z - 1,
|
|
@@ -7997,7 +7917,7 @@ var DirectionalLight = class extends Light {
|
|
|
7997
7917
|
return frustum_corners;
|
|
7998
7918
|
}
|
|
7999
7919
|
get_light_space_matrix(light_dir, corners) {
|
|
8000
|
-
const center = new
|
|
7920
|
+
const center = new Vec35(0, 0, 0);
|
|
8001
7921
|
for (const v of corners) center.add(v.xyz);
|
|
8002
7922
|
center.div(corners.length);
|
|
8003
7923
|
let radius = 0;
|
|
@@ -8006,13 +7926,13 @@ var DirectionalLight = class extends Light {
|
|
|
8006
7926
|
}
|
|
8007
7927
|
if (this.engine.main_scene.main_camera_3d)
|
|
8008
7928
|
radius /= this.engine.main_scene.main_camera_3d.far_plane;
|
|
8009
|
-
const world_up = new
|
|
7929
|
+
const world_up = new Vec35(0, 1, 0);
|
|
8010
7930
|
const normalized_dir = light_dir.clone().normalize();
|
|
8011
7931
|
let up = world_up;
|
|
8012
7932
|
if (Math.abs(normalized_dir.dot(world_up)) > 0.99) {
|
|
8013
|
-
up = new
|
|
7933
|
+
up = new Vec35(0, 0, 1);
|
|
8014
7934
|
}
|
|
8015
|
-
const light_view = new
|
|
7935
|
+
const light_view = new Mat46().lookAt(
|
|
8016
7936
|
center.clone().sub(normalized_dir.clone().mul(radius)),
|
|
8017
7937
|
center,
|
|
8018
7938
|
up
|
|
@@ -8035,12 +7955,12 @@ var DirectionalLight = class extends Light {
|
|
|
8035
7955
|
const z_margin = 10;
|
|
8036
7956
|
min_z -= z_margin;
|
|
8037
7957
|
max_z += z_margin;
|
|
8038
|
-
return new
|
|
7958
|
+
return new Mat46().orthoZO(min_x, max_x, min_y, max_y, max_z, min_z).mul(light_view);
|
|
8039
7959
|
}
|
|
8040
7960
|
};
|
|
8041
7961
|
|
|
8042
7962
|
// src/node/lights/spot_light.ts
|
|
8043
|
-
|
|
7963
|
+
import { Mat3 as Mat33, Mat4 as Mat47, Quat as Quat4, Vec3 as Vec36, Vec4 as Vec47 } from "@vicimpa/glm";
|
|
8044
7964
|
var SpotLight = class extends Light {
|
|
8045
7965
|
constructor(engine, name, color, ambient, diffuse, specular, energy, range, cookie_radius) {
|
|
8046
7966
|
super(engine, name, color, ambient, diffuse, specular, energy);
|
|
@@ -8052,11 +7972,11 @@ var SpotLight = class extends Light {
|
|
|
8052
7972
|
}
|
|
8053
7973
|
set_uniforms(array_name, index) {
|
|
8054
7974
|
const world_matrix = this.get_world_matrix();
|
|
8055
|
-
const transformed_position = new
|
|
8056
|
-
const world_mat3 = new
|
|
8057
|
-
const world_rotation = new
|
|
8058
|
-
const world_rotation_matrix = new
|
|
8059
|
-
this.engine.graphics_manager.set_uniform(`${array_name}[${index}].position`, new
|
|
7975
|
+
const transformed_position = new Vec47(this.position.x, this.position.y, this.position.z, 1).applyMat4(world_matrix);
|
|
7976
|
+
const world_mat3 = new Mat33().fromMat4(world_matrix);
|
|
7977
|
+
const world_rotation = new Quat4().fromMat3(world_mat3).normalize();
|
|
7978
|
+
const world_rotation_matrix = new Mat47().fromQuat(world_rotation);
|
|
7979
|
+
this.engine.graphics_manager.set_uniform(`${array_name}[${index}].position`, new Vec36(world_matrix[12], world_matrix[13], world_matrix[14]));
|
|
8060
7980
|
this.engine.graphics_manager.set_uniform(`${array_name}[${index}].rotation`, world_rotation_matrix);
|
|
8061
7981
|
this.engine.graphics_manager.set_uniform(`${array_name}[${index}].range`, this.range);
|
|
8062
7982
|
this.engine.graphics_manager.set_uniform(`${array_name}[${index}].cookie_radius`, this.cookie_radius);
|
|
@@ -8240,7 +8160,7 @@ var Utility = class {
|
|
|
8240
8160
|
|
|
8241
8161
|
// src/hook_manager.ts
|
|
8242
8162
|
var import_wasmoon = __toESM(require_dist(), 1);
|
|
8243
|
-
|
|
8163
|
+
import { Vec2 as Vec24, Vec3 as Vec37, Vec4 as Vec48, Mat2 as Mat22, Mat3 as Mat34, Mat4 as Mat48, Quat as Quat5 } from "@vicimpa/glm";
|
|
8244
8164
|
var HookManager = class {
|
|
8245
8165
|
constructor(engine) {
|
|
8246
8166
|
this.lua = null;
|
|
@@ -8315,13 +8235,13 @@ var HookManager = class {
|
|
|
8315
8235
|
await this.lua_engine_promise;
|
|
8316
8236
|
if (!this.lua)
|
|
8317
8237
|
return;
|
|
8318
|
-
this.lua.global.set("Vec2", create_lua_constructor(
|
|
8319
|
-
this.lua.global.set("Vec3", create_lua_constructor(
|
|
8320
|
-
this.lua.global.set("Vec4", create_lua_constructor(
|
|
8321
|
-
this.lua.global.set("Mat2", create_lua_constructor(
|
|
8322
|
-
this.lua.global.set("Mat3", create_lua_constructor(
|
|
8323
|
-
this.lua.global.set("Mat4", create_lua_constructor(
|
|
8324
|
-
this.lua.global.set("Quat", create_lua_constructor(
|
|
8238
|
+
this.lua.global.set("Vec2", create_lua_constructor(Vec24));
|
|
8239
|
+
this.lua.global.set("Vec3", create_lua_constructor(Vec37));
|
|
8240
|
+
this.lua.global.set("Vec4", create_lua_constructor(Vec48));
|
|
8241
|
+
this.lua.global.set("Mat2", create_lua_constructor(Mat22));
|
|
8242
|
+
this.lua.global.set("Mat3", create_lua_constructor(Mat34));
|
|
8243
|
+
this.lua.global.set("Mat4", create_lua_constructor(Mat48));
|
|
8244
|
+
this.lua.global.set("Quat", create_lua_constructor(Quat5));
|
|
8325
8245
|
this.lua.global.set("Node", create_lua_constructor(Node));
|
|
8326
8246
|
this.lua.global.set("Node3D", create_lua_constructor(Node3D));
|
|
8327
8247
|
this.lua.global.set("Node2D", create_lua_constructor(Node2D));
|
|
@@ -8404,4 +8324,46 @@ var Engine = class {
|
|
|
8404
8324
|
|
|
8405
8325
|
// src/index.ts
|
|
8406
8326
|
var index_default = Engine;
|
|
8407
|
-
|
|
8327
|
+
export {
|
|
8328
|
+
AssetFile,
|
|
8329
|
+
AttachmentType,
|
|
8330
|
+
Camera3D,
|
|
8331
|
+
CubeMapTexture,
|
|
8332
|
+
DirectionalLight,
|
|
8333
|
+
DrawFlag,
|
|
8334
|
+
Framebuffer,
|
|
8335
|
+
GraphicsManager,
|
|
8336
|
+
HookManager,
|
|
8337
|
+
InputManager,
|
|
8338
|
+
Light,
|
|
8339
|
+
Material,
|
|
8340
|
+
Mesh,
|
|
8341
|
+
Model,
|
|
8342
|
+
MouseButton,
|
|
8343
|
+
Node,
|
|
8344
|
+
Node2D,
|
|
8345
|
+
Node3D,
|
|
8346
|
+
Object3D,
|
|
8347
|
+
PointLight,
|
|
8348
|
+
Scene,
|
|
8349
|
+
ShaderProgram,
|
|
8350
|
+
Skybox,
|
|
8351
|
+
SpotLight,
|
|
8352
|
+
Sprite2D,
|
|
8353
|
+
Texture,
|
|
8354
|
+
TextureType,
|
|
8355
|
+
WebGLUniformType,
|
|
8356
|
+
basename_path,
|
|
8357
|
+
index_default as default,
|
|
8358
|
+
degrees_to_radians,
|
|
8359
|
+
dirname_path,
|
|
8360
|
+
get_skybox_vao,
|
|
8361
|
+
get_sprite_vao,
|
|
8362
|
+
get_uniform_label_index,
|
|
8363
|
+
has_flag,
|
|
8364
|
+
join_path,
|
|
8365
|
+
load_obj,
|
|
8366
|
+
normalize_uniform_label,
|
|
8367
|
+
parse_path
|
|
8368
|
+
};
|
|
8369
|
+
//# sourceMappingURL=index.mjs.map
|