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