@carbonenginejs/core-math 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cppctamber / CarbonEngineJS contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,24 @@
1
+ carbonenginejs/core-math
2
+ ========================
3
+
4
+ A browser-friendly gl-matrix based math package for CarbonEngineJS projects.
5
+ It contains standalone math containers originally extracted from ccpwgl's
6
+ `src/global/math` library, plus shared mesh and tangent helpers that replace
7
+ duplicated code in the CarbonEngineJS format packages.
8
+
9
+ CarbonEngine and Fenris Creations (CCP Games) are named here for provenance,
10
+ interoperability, and target-ecosystem context. This package contains no
11
+ CarbonEngine or Fenris Creations (CCP Games) source files, tooling, proprietary
12
+ documentation, shader source, or assets.
13
+
14
+ Packed tangent-frame behavior is based on observed Fenris Creations
15
+ (CCP Games) EVE/Carbon shader behavior and generated test vectors, not copied
16
+ shader source.
17
+
18
+ This package is not affiliated with or endorsed by CCP Games.
19
+
20
+ CarbonEngineJS-facing code is copyright cppctamber / CarbonEngineJS
21
+ contributors.
22
+
23
+ Repository license: MIT. See LICENSE and THIRD-PARTY-NOTICES.md.
24
+
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @carbonenginejs/core-math
2
+
3
+ Browser-friendly gl-matrix based math containers for CarbonEngineJS packages.
4
+ The package exposes small parent containers such as `num`, `vec3`, `mat4`,
5
+ `mesh`, and `tangent`, and also supports subpath imports so callers do not need
6
+ to import the full math surface.
7
+
8
+ CarbonEngine and Fenris Creations (CCP Games) are named for provenance and
9
+ interoperability context. This package contains no CarbonEngine or Fenris
10
+ Creations (CCP Games) source code, shader source, proprietary documentation,
11
+ tools, or assets.
12
+
13
+ ## Package
14
+
15
+ - npm: <https://www.npmjs.com/package/@carbonenginejs/core-math>
16
+ - package: `@carbonenginejs/core-math`
17
+ - version: `0.1.0`
18
+ - license: `MIT`
19
+ - runtime: modern browsers, Node `>=18`
20
+ - module: ESM
21
+ - dependency: `gl-matrix ^3.4.4`
22
+
23
+ ## Install
24
+
25
+ ```sh
26
+ npm install @carbonenginejs/core-math
27
+ ```
28
+
29
+ ## Public API
30
+
31
+ Prefer direct subpath imports when a package only needs a few math methods:
32
+
33
+ ```js
34
+ import { cross, normalize } from "@carbonenginejs/core-math/vec3";
35
+
36
+ const out = [0, 0, 0];
37
+ cross(out, edgeA, edgeB);
38
+ normalize(out, out);
39
+ ```
40
+
41
+ Subpaths can also be imported as module namespaces:
42
+
43
+ ```js
44
+ import * as vec3 from "@carbonenginejs/core-math/vec3";
45
+
46
+ vec3.cross(out, edgeA, edgeB);
47
+ vec3.normalize(out, out);
48
+ ```
49
+
50
+ Existing container exports remain available from subpaths while callers migrate:
51
+
52
+ ```js
53
+ import { vec3 } from "@carbonenginejs/core-math/vec3";
54
+ import { mesh } from "@carbonenginejs/core-math/mesh";
55
+ import { tangent } from "@carbonenginejs/core-math/tangent";
56
+
57
+ vec3.cross(out, edgeA, edgeB);
58
+ const n = mesh.generateNormals(positions, indices);
59
+ const t = mesh.generateTangents(positions, n, uvs, indices);
60
+ const b = mesh.generateBiNormals(n, t);
61
+ const packed = tangent.packTangentFrames(n, t, b);
62
+ ```
63
+
64
+ Use root imports when several namespaces are needed:
65
+
66
+ ```js
67
+ import { num, vec3, mat4, mesh, tangent } from "@carbonenginejs/core-math";
68
+
69
+ num.clamp(value, 0, 1);
70
+ vec3.cross(out, a, b);
71
+ vec3.normalize(out, out);
72
+ mat4.identity(world);
73
+ const packed = tangent.packTangentFrames(normals, tangents, binormals);
74
+ ```
75
+
76
+ `vertex` is a legacy compatibility container backed by the shared mesh/tangent
77
+ helpers. Its tangent generation intentionally does not preserve the older
78
+ ccpwgl `vertex.js` implementation.
79
+
80
+ ## Containers
81
+
82
+ - `num`: scalar helpers and color/angle conversion helpers.
83
+ - `vec2`, `vec3`, `vec4`, `quat`, `mat3`, `mat4`: gl-matrix containers with
84
+ CarbonEngineJS additions.
85
+ - `box3`, `tri3`, `lne3`, `pln`, `ray3`, `sph3`: spatial helper containers.
86
+ - `pool`: typed-array buffer pool helper.
87
+ - `noise`, `curve`: extracted ccpwgl math helpers.
88
+ - `mesh`: shared mesh rebuild helpers used by format packages.
89
+ - `tangent`: CarbonEngineJS/GR2 packed tangent-frame helpers.
90
+ - `vertex`: compatibility names for mesh/tangent generation.
91
+ - `geometry`: extracted procedural geometry helpers.
92
+
93
+ ## Browser Rules
94
+
95
+ Runtime source is plain ESM and must not depend on Node built-ins, filesystem
96
+ helpers, CLI tools, webpack aliases, or ccpwgl application globals. Tests may
97
+ run in Node, but package code must remain browser-safe.
98
+
99
+ ## Tests
100
+
101
+ ```sh
102
+ npm test
103
+ ```
104
+
105
+ Tests are self-contained and do not require local asset folders, network
106
+ access, or game files.
107
+
108
+ ## License
109
+
110
+ MIT (see `LICENSE`, `NOTICE`, and `THIRD-PARTY-NOTICES.md`).
@@ -0,0 +1,38 @@
1
+ # Third-Party Notices
2
+
3
+ ## gl-matrix
4
+
5
+ This package depends on `gl-matrix` and extends its vector, quaternion, and
6
+ matrix containers with CarbonEngineJS helpers.
7
+
8
+ - Project: <https://github.com/toji/gl-matrix>
9
+ - License: MIT
10
+
11
+ ## ccpwgl math extraction
12
+
13
+ Most container modules in `src` were extracted from ccpwgl's
14
+ `src/global/math` library and converted to standalone ESM with package-local
15
+ imports. The code remains MIT-licensed under the CarbonEngineJS/ccpwgl project
16
+ license.
17
+
18
+ ## Mapbox earcut helper
19
+
20
+ `src/geometry/helpers/earcut.js` is an embedded copy of an Earcut-style
21
+ triangulation helper from the ccpwgl math tree.
22
+
23
+ - Copyright: 2016, Mapbox
24
+ - License: ISC
25
+ - Local license copy: `src/geometry/helpers/LICENSE`
26
+
27
+ ## Three.js-derived geometry notes
28
+
29
+ Some geometry helpers in the extracted ccpwgl math tree are marked as converted
30
+ from Three.js-style algorithms. These are retained as source comments and should
31
+ be reviewed before expanding the public geometry surface.
32
+
33
+ ## Fenris Creations / CCP Games tangent behavior
34
+
35
+ `src/tangent.js` implements CarbonEngineJS/GR2 packed tangent-frame behavior
36
+ derived from observed EVE/Carbon shader behavior and generated test vectors.
37
+ No Fenris Creations (CCP Games) shader source, tools, or assets are included.
38
+
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@carbonenginejs/core-math",
3
+ "version": "0.1.0",
4
+ "description": "Browser-friendly gl-matrix based math containers and CarbonEngineJS mesh/tangent helpers.",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js",
9
+ "./num": "./src/num.js",
10
+ "./vec2": "./src/vec2.js",
11
+ "./vec3": "./src/vec3.js",
12
+ "./vec4": "./src/vec4.js",
13
+ "./quat": "./src/quat.js",
14
+ "./mat3": "./src/mat3.js",
15
+ "./mat4": "./src/mat4.js",
16
+ "./box3": "./src/box3.js",
17
+ "./tri3": "./src/tri3.js",
18
+ "./lne3": "./src/lne3.js",
19
+ "./pln": "./src/pln.js",
20
+ "./ray3": "./src/ray3.js",
21
+ "./sph3": "./src/sph3.js",
22
+ "./pool": "./src/pool.js",
23
+ "./noise": "./src/noise.js",
24
+ "./curve": "./src/curve.js",
25
+ "./vertex": "./src/vertex.js",
26
+ "./mesh": "./src/mesh.js",
27
+ "./tangent": "./src/tangent.js",
28
+ "./geometry": "./src/geometry/index.js"
29
+ },
30
+ "sideEffects": false,
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "scripts": {
35
+ "test": "node --test",
36
+ "lint": "eslint --ext .js,.mjs src test",
37
+ "lint:fix": "eslint --fix --ext .js,.mjs src test"
38
+ },
39
+ "keywords": [
40
+ "carbonenginejs",
41
+ "core-math",
42
+ "gl-matrix",
43
+ "geometry",
44
+ "tangent",
45
+ "mesh",
46
+ "browser"
47
+ ],
48
+ "files": [
49
+ "src",
50
+ "README.md",
51
+ "LICENSE",
52
+ "NOTICE",
53
+ "THIRD-PARTY-NOTICES.md"
54
+ ],
55
+ "license": "MIT",
56
+ "dependencies": {
57
+ "gl-matrix": "^3.4.4"
58
+ },
59
+ "devDependencies": {
60
+ "eslint": "^8.57.1"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/carbonenginejs/core-math.git"
65
+ },
66
+ "homepage": "https://github.com/carbonenginejs/core-math#readme",
67
+ "bugs": {
68
+ "url": "https://github.com/carbonenginejs/core-math/issues"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ }
73
+ }
74
+