@dice-o-rolla/dice-engine 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,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Dice O Rolla
2
+ Copyright 2026 Dmitriy Pyankov
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # `@dice-o-rolla/dice-engine`
2
+
3
+ Framework-neutral orchestration for physically simulated polyhedral dice. The package exposes a
4
+ backend-neutral engine and an optional browser composition backed by Rapier and Three.js.
5
+
6
+ ## Browser usage
7
+
8
+ ```ts
9
+ import { createDefaultDiceEngine } from '@dice-o-rolla/dice-engine/browser';
10
+
11
+ const container = document.querySelector<HTMLElement>('#dice-tray');
12
+ if (container === null) throw new Error('Missing dice tray');
13
+
14
+ const engine = await createDefaultDiceEngine({ container });
15
+ const result = await engine.roll('2d20 + 4');
16
+
17
+ console.log(result.total, result.dice);
18
+ engine.destroy();
19
+ ```
20
+
21
+ The browser entry point initializes Rapier WASM, creates the Three.js renderer, uses Web Crypto for
22
+ throw generation, and releases partially initialized resources if composition fails.
23
+
24
+ ## Custom adapters
25
+
26
+ ```ts
27
+ import { DiceEngine } from '@dice-o-rolla/dice-engine';
28
+
29
+ const engine = new DiceEngine({ physics, renderer });
30
+ await engine.initialize();
31
+ ```
32
+
33
+ The main entry point depends on domain contracts rather than concrete Rapier or Three.js types.
34
+
35
+ ## Supported notation
36
+
37
+ The initial grammar supports standard polyhedral expressions and integer modifiers, including:
38
+
39
+ ```text
40
+ d20
41
+ 4d6 + 2
42
+ d%
43
+ d100
44
+ d66
45
+ ```
46
+
47
+ Default resource limits reject oversized notation, more than 50 logical or physical dice, and more
48
+ than eight pending rolls. Consumers may lower or explicitly raise these limits through
49
+ `DiceEngineOptions.limits` after testing their target devices.
50
+
51
+ ## Trust and cleanup
52
+
53
+ Client-side results are not authoritative for rankings, prizes, or wagering. Call `destroy()` when
54
+ the engine is no longer needed to release frame scheduling, observers, physics resources, WebGL
55
+ resources, and the renderer canvas.
56
+
57
+ ## License
58
+
59
+ Licensed under the Apache License, Version 2.0. The package archive includes `LICENSE`, `NOTICE`, and
60
+ `THIRD_PARTY_NOTICES.md`.
@@ -0,0 +1,18 @@
1
+ # Third-party notices
2
+
3
+ ## 3DDiceRoller
4
+
5
+ The geometry model and physical dice behavior were informed by 3DDiceRoller by MajorVictory,
6
+ released under The Unlicense.
7
+
8
+ - Source: <https://github.com/MajorVictory/3DDiceRoller>
9
+ - License: <https://unlicense.org/>
10
+
11
+ ## Runtime dependencies
12
+
13
+ - Three.js is distributed under the MIT License: <https://github.com/mrdoob/three.js>.
14
+ - Rapier is distributed under the Apache License 2.0:
15
+ <https://github.com/dimforge/rapier.js>.
16
+
17
+ The UNLICENSED anvil-dice-engine project was used only for architectural comparison. No source code,
18
+ assets, sounds, shaders, or textures from that project are included in this distribution.
@@ -0,0 +1,11 @@
1
+ import { type RapierPhysicsWorldOptions } from '@dice-o-rolla/dice-physics-rapier';
2
+ import { type ThreeDiceRendererOptions } from '@dice-o-rolla/dice-renderer-three';
3
+ import type { DiceEngine } from './dice-engine.js';
4
+ import type { DiceEngineOptions } from './types.js';
5
+ export interface DefaultDiceEngineOptions {
6
+ readonly container: HTMLElement;
7
+ readonly physics?: RapierPhysicsWorldOptions;
8
+ readonly renderer?: ThreeDiceRendererOptions;
9
+ readonly engine?: Omit<DiceEngineOptions, 'physics' | 'renderer'>;
10
+ }
11
+ export declare function createDefaultDiceEngine(options: DefaultDiceEngineOptions): Promise<DiceEngine>;
@@ -0,0 +1,12 @@
1
+ /// <reference lib="dom" />
2
+ import { cryptoRandomSource } from '@dice-o-rolla/dice-core';
3
+ import { RapierPhysics } from '@dice-o-rolla/dice-physics-rapier';
4
+ import { ThreeDiceRenderer, } from '@dice-o-rolla/dice-renderer-three';
5
+ import { initializeOwnedDiceEngine } from './composition.js';
6
+ export async function createDefaultDiceEngine(options) {
7
+ const physics = await RapierPhysics.create(options.physics);
8
+ return initializeOwnedDiceEngine(physics, () => new ThreeDiceRenderer(options.container, options.renderer), {
9
+ ...options.engine,
10
+ random: options.engine?.random ?? cryptoRandomSource,
11
+ });
12
+ }
@@ -0,0 +1,5 @@
1
+ import type { PhysicsWorld } from '@dice-o-rolla/dice-physics';
2
+ import type { DiceRenderer } from '@dice-o-rolla/dice-renderer';
3
+ import { DiceEngine } from './dice-engine.js';
4
+ import type { DiceEngineOptions } from './types.js';
5
+ export declare function initializeOwnedDiceEngine(physics: PhysicsWorld, createRenderer: () => DiceRenderer, options: Omit<DiceEngineOptions, 'physics' | 'renderer'>): Promise<DiceEngine>;
@@ -0,0 +1,31 @@
1
+ import { DiceEngine } from './dice-engine.js';
2
+ export async function initializeOwnedDiceEngine(physics, createRenderer, options) {
3
+ let renderer;
4
+ try {
5
+ renderer = createRenderer();
6
+ const engine = new DiceEngine({ ...options, physics, renderer });
7
+ await engine.initialize();
8
+ return engine;
9
+ }
10
+ catch (error) {
11
+ const cleanupErrors = [];
12
+ try {
13
+ renderer?.destroy();
14
+ }
15
+ catch (cleanupError) {
16
+ cleanupErrors.push(cleanupError);
17
+ }
18
+ try {
19
+ physics.destroy();
20
+ }
21
+ catch (cleanupError) {
22
+ cleanupErrors.push(cleanupError);
23
+ }
24
+ if (cleanupErrors.length > 0) {
25
+ throw new AggregateError([error, ...cleanupErrors], 'Dice engine initialization failed', {
26
+ cause: error,
27
+ });
28
+ }
29
+ throw error;
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ import type { DiceTheme, FrameScheduler } from './types.js';
2
+ export declare const DEFAULT_THEME: DiceTheme;
3
+ export declare const defaultFrameScheduler: FrameScheduler;
@@ -0,0 +1,19 @@
1
+ export const DEFAULT_THEME = Object.freeze({
2
+ material: 'plastic',
3
+ bodyColor: '#f7f3e8',
4
+ labelColor: '#181818',
5
+ roughness: 0.28,
6
+ metalness: 0,
7
+ });
8
+ export const defaultFrameScheduler = {
9
+ request(callback) {
10
+ const animationFrame = globalThis;
11
+ if (typeof animationFrame.requestAnimationFrame === 'function' &&
12
+ typeof animationFrame.cancelAnimationFrame === 'function') {
13
+ const handle = animationFrame.requestAnimationFrame(callback);
14
+ return { cancel: () => animationFrame.cancelAnimationFrame?.(handle) };
15
+ }
16
+ const handle = setTimeout(() => callback(performance.now()), 16);
17
+ return { cancel: () => clearTimeout(handle) };
18
+ },
19
+ };
@@ -0,0 +1,16 @@
1
+ import { TypedEventEmitter } from '@dice-o-rolla/dice-core';
2
+ import type { RollResult } from '@dice-o-rolla/dice-core';
3
+ import type { RendererViewport } from '@dice-o-rolla/dice-renderer';
4
+ import type { DiceEngineEvents, DiceEngineFacade, DiceEngineOptions, DiceTheme, RollOptions } from './types.js';
5
+ export declare class DiceEngine extends TypedEventEmitter<DiceEngineEvents> implements DiceEngineFacade {
6
+ #private;
7
+ constructor(options: DiceEngineOptions);
8
+ initialize(): Promise<void>;
9
+ roll(notation: string, options?: RollOptions): Promise<RollResult>;
10
+ cancel(sessionId?: string): boolean;
11
+ clear(): void;
12
+ resize(viewport: RendererViewport): void;
13
+ setTheme(theme: Partial<DiceTheme>): DiceTheme;
14
+ get theme(): DiceTheme;
15
+ destroy(): void;
16
+ }
@@ -0,0 +1,583 @@
1
+ import { createRollResult, getNotationModifier, isDieType, mathRandomSource, parseNotation, TypedEventEmitter, } from '@dice-o-rolla/dice-core';
2
+ import { getDieGeometry, hasDieGeometry, resolveFace } from '@dice-o-rolla/dice-geometry';
3
+ import { SettlingDetector, ThrowGenerator } from '@dice-o-rolla/dice-physics';
4
+ import { DEFAULT_THEME, defaultFrameScheduler } from './defaults.js';
5
+ import { DiceEngineDestroyedError, RollCancelledError, RollLimitExceededError, RollTimeoutError, } from './errors.js';
6
+ const DEFAULT_SETTLING = {
7
+ linearVelocityThreshold: 0.08,
8
+ angularVelocityThreshold: 0.08,
9
+ stableTimeMs: 300,
10
+ maxRollTimeMs: 10_000,
11
+ };
12
+ const DEFAULT_THROW = {
13
+ position: {
14
+ x: { min: -2, max: 2 },
15
+ y: { min: 3.5, max: 5 },
16
+ z: { min: -2, max: 2 },
17
+ },
18
+ impulse: {
19
+ x: { min: -2.5, max: 2.5 },
20
+ y: { min: 0.5, max: 2 },
21
+ z: { min: -2.5, max: 2.5 },
22
+ },
23
+ torqueImpulse: {
24
+ x: { min: -3, max: 3 },
25
+ y: { min: -3, max: 3 },
26
+ z: { min: -3, max: 3 },
27
+ },
28
+ };
29
+ const DEFAULT_TRAY = {
30
+ width: 10,
31
+ depth: 10,
32
+ wallHeight: 6,
33
+ wallThickness: 0.25,
34
+ material: { friction: 0.8, restitution: 0.1 },
35
+ };
36
+ const DEFAULT_DICE_MATERIAL = {
37
+ friction: 0.7,
38
+ restitution: 0.15,
39
+ linearDamping: 0.25,
40
+ angularDamping: 0.25,
41
+ };
42
+ const DEFAULT_LIMITS = Object.freeze({
43
+ maxNotationLength: 256,
44
+ maxLogicalDice: 50,
45
+ maxPhysicalDice: 50,
46
+ maxQueuedRolls: 8,
47
+ });
48
+ const D100_TENS_LABELS = Object.freeze({
49
+ 1: 10,
50
+ 2: 20,
51
+ 3: 30,
52
+ 4: 40,
53
+ 5: 50,
54
+ 6: 60,
55
+ 7: 70,
56
+ 8: 80,
57
+ 9: 90,
58
+ 10: '00',
59
+ });
60
+ const D66_TENS_LABELS = Object.freeze({ 1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60 });
61
+ function snapshotSession(session) {
62
+ return Object.freeze({
63
+ id: session.id,
64
+ notation: session.notation,
65
+ state: session.state,
66
+ createdAt: session.createdAt,
67
+ ...(session.startedAt === undefined ? {} : { startedAt: session.startedAt }),
68
+ ...(session.completedAt === undefined ? {} : { completedAt: session.completedAt }),
69
+ });
70
+ }
71
+ function toRenderState(die) {
72
+ return {
73
+ id: die.id,
74
+ geometryId: die.geometryType,
75
+ ...(die.faceLabels === undefined ? {} : { faceLabels: die.faceLabels }),
76
+ previous: die.previous,
77
+ current: die.current,
78
+ };
79
+ }
80
+ function assertPositive(value, name) {
81
+ if (!Number.isFinite(value) || value <= 0) {
82
+ throw new RangeError(`${name} must be a positive finite number`);
83
+ }
84
+ }
85
+ function assertPositiveSafeInteger(value, name) {
86
+ if (!Number.isSafeInteger(value) || value <= 0) {
87
+ throw new RangeError(`${name} must be a positive safe integer`);
88
+ }
89
+ }
90
+ export class DiceEngine extends TypedEventEmitter {
91
+ #physics;
92
+ #renderer;
93
+ #scheduler;
94
+ #now;
95
+ #fixedStepSeconds;
96
+ #maxFrameDeltaSeconds;
97
+ #settling;
98
+ #throwGenerator;
99
+ #tray;
100
+ #diceMaterial;
101
+ #limits;
102
+ #queue = [];
103
+ #displayedDieIds = new Set();
104
+ #active;
105
+ #frameToken;
106
+ #lastFrameMs = 0;
107
+ #accumulatorSeconds = 0;
108
+ #nextSessionId = 1;
109
+ #initialized = false;
110
+ #destroyed = false;
111
+ #theme;
112
+ constructor(options) {
113
+ super();
114
+ this.#physics = options.physics;
115
+ this.#renderer = options.renderer;
116
+ this.#scheduler = options.scheduler ?? defaultFrameScheduler;
117
+ this.#now = options.now ?? (() => performance.now());
118
+ this.#fixedStepSeconds = options.fixedStepSeconds ?? 1 / 60;
119
+ this.#maxFrameDeltaSeconds = options.maxFrameDeltaSeconds ?? 0.25;
120
+ assertPositive(this.#fixedStepSeconds, 'fixedStepSeconds');
121
+ assertPositive(this.#maxFrameDeltaSeconds, 'maxFrameDeltaSeconds');
122
+ this.#settling = options.settling ?? DEFAULT_SETTLING;
123
+ this.#throwGenerator = new ThrowGenerator(options.random ?? mathRandomSource, options.throw ?? DEFAULT_THROW);
124
+ this.#tray = options.tray ?? DEFAULT_TRAY;
125
+ this.#diceMaterial = options.diceMaterial ?? DEFAULT_DICE_MATERIAL;
126
+ this.#limits = Object.freeze({ ...DEFAULT_LIMITS, ...options.limits });
127
+ for (const [name, value] of [
128
+ ['maxNotationLength', this.#limits.maxNotationLength],
129
+ ['maxLogicalDice', this.#limits.maxLogicalDice],
130
+ ['maxPhysicalDice', this.#limits.maxPhysicalDice],
131
+ ['maxQueuedRolls', this.#limits.maxQueuedRolls],
132
+ ]) {
133
+ assertPositiveSafeInteger(value, `limits.${name}`);
134
+ }
135
+ this.#theme = this.#mergeTheme(options.theme ?? {});
136
+ }
137
+ async initialize() {
138
+ this.#assertAlive();
139
+ if (this.#initialized)
140
+ return;
141
+ this.#physics.configureTray(this.#tray);
142
+ await this.#renderer.initialize();
143
+ this.#renderer.setTheme(this.#theme);
144
+ this.#initialized = true;
145
+ }
146
+ roll(notation, options = {}) {
147
+ try {
148
+ this.#assertReady();
149
+ if ((options.mode ?? 'queue') !== 'queue') {
150
+ throw new RangeError('Only queue roll mode is currently supported');
151
+ }
152
+ if (notation.length > this.#limits.maxNotationLength) {
153
+ throw new RollLimitExceededError('notation-length', this.#limits.maxNotationLength, notation.length);
154
+ }
155
+ const parsed = parseNotation(notation);
156
+ this.#assertSupportedAndWithinLimits(parsed);
157
+ if (this.#active !== undefined && this.#queue.length >= this.#limits.maxQueuedRolls) {
158
+ throw new RollLimitExceededError('queue-size', this.#limits.maxQueuedRolls, this.#queue.length + 1);
159
+ }
160
+ const task = this.#createTask(notation, parsed, options.signal);
161
+ if (options.signal?.aborted === true) {
162
+ this.#rejectCancelled(task);
163
+ return task.promise;
164
+ }
165
+ this.#queue.push(task);
166
+ this.#startNext();
167
+ return task.promise;
168
+ }
169
+ catch (error) {
170
+ return Promise.reject(error);
171
+ }
172
+ }
173
+ cancel(sessionId) {
174
+ this.#assertAlive();
175
+ if (this.#active !== undefined &&
176
+ (sessionId === undefined || this.#active.task.session.id === sessionId)) {
177
+ const task = this.#active.task;
178
+ this.#cancelActive(task);
179
+ return true;
180
+ }
181
+ const index = this.#queue.findIndex((task) => sessionId === undefined || task.session.id === sessionId);
182
+ const task = index < 0 ? undefined : this.#queue.splice(index, 1)[0];
183
+ if (task === undefined)
184
+ return false;
185
+ this.#rejectCancelled(task);
186
+ return true;
187
+ }
188
+ clear() {
189
+ this.#assertAlive();
190
+ this.#frameToken?.cancel();
191
+ this.#frameToken = undefined;
192
+ if (this.#active !== undefined) {
193
+ const task = this.#active.task;
194
+ this.#active = undefined;
195
+ this.#rejectCancelled(task);
196
+ }
197
+ for (const task of this.#queue.splice(0))
198
+ this.#rejectCancelled(task);
199
+ this.#physics.clear();
200
+ this.#renderer.clear();
201
+ this.#displayedDieIds.clear();
202
+ this.#accumulatorSeconds = 0;
203
+ }
204
+ resize(viewport) {
205
+ this.#assertReady();
206
+ this.#renderer.resize(viewport);
207
+ }
208
+ setTheme(theme) {
209
+ this.#assertAlive();
210
+ this.#theme = this.#mergeTheme({ ...this.#theme, ...theme });
211
+ if (this.#initialized)
212
+ this.#renderer.setTheme(this.#theme);
213
+ this.emit('theme:change', this.#theme);
214
+ return this.#theme;
215
+ }
216
+ get theme() {
217
+ return this.#theme;
218
+ }
219
+ destroy() {
220
+ if (this.#destroyed)
221
+ return;
222
+ this.clear();
223
+ this.#renderer.destroy();
224
+ this.#physics.destroy();
225
+ super.clear();
226
+ this.#initialized = false;
227
+ this.#destroyed = true;
228
+ }
229
+ #createTask(notation, parsed, signal) {
230
+ const session = {
231
+ id: `roll-${this.#nextSessionId++}`,
232
+ notation,
233
+ state: 'pending',
234
+ createdAt: this.#now(),
235
+ };
236
+ let resolve;
237
+ let reject;
238
+ const promise = new Promise((resolvePromise, rejectPromise) => {
239
+ resolve = resolvePromise;
240
+ reject = rejectPromise;
241
+ });
242
+ const abortListener = signal === undefined ? undefined : () => void this.cancel(session.id);
243
+ if (abortListener !== undefined)
244
+ signal?.addEventListener('abort', abortListener, { once: true });
245
+ return {
246
+ session,
247
+ parsed,
248
+ promise,
249
+ resolve,
250
+ reject,
251
+ ...(signal === undefined ? {} : { signal }),
252
+ ...(abortListener === undefined ? {} : { abortListener }),
253
+ };
254
+ }
255
+ #startNext() {
256
+ if (this.#active !== undefined || this.#queue.length === 0)
257
+ return;
258
+ const task = this.#queue.shift();
259
+ if (task === undefined)
260
+ return;
261
+ this.#removeDisplayedDice();
262
+ task.session.state = 'rolling';
263
+ task.session.startedAt = this.#now();
264
+ try {
265
+ const dice = this.#createDice(task);
266
+ this.#active = { task, dice };
267
+ this.emit('roll:start', snapshotSession(task.session));
268
+ this.#lastFrameMs = this.#now();
269
+ this.#accumulatorSeconds = 0;
270
+ this.#scheduleFrame();
271
+ }
272
+ catch (error) {
273
+ const active = this.#active;
274
+ if (active?.task === task)
275
+ this.#failActive(active, error);
276
+ else
277
+ this.#failTask(task, error);
278
+ }
279
+ }
280
+ #createDice(task) {
281
+ const dice = [];
282
+ let index = 0;
283
+ const specs = this.#createPhysicalSpecs(task);
284
+ const totalDice = specs.length;
285
+ try {
286
+ for (const spec of specs) {
287
+ const geometry = getDieGeometry(spec.geometryType);
288
+ const id = `${task.session.id}:die-${index++}`;
289
+ const generated = this.#throwGenerator.generate();
290
+ const position = this.#placeDie(generated.position, index - 1, totalDice);
291
+ const body = this.#physics.createDie({
292
+ id,
293
+ type: spec.geometryType,
294
+ collider: {
295
+ kind: 'convex-hull',
296
+ vertices: geometry.vertices.map(([x, y, z]) => ({ x, y, z })),
297
+ },
298
+ scale: 1,
299
+ mass: 1,
300
+ material: this.#diceMaterial,
301
+ position,
302
+ quaternion: generated.quaternion,
303
+ });
304
+ const state = body.getState();
305
+ const die = {
306
+ id,
307
+ type: spec.type,
308
+ geometryType: spec.geometryType,
309
+ ...(spec.component === undefined ? {} : { component: spec.component }),
310
+ ...(spec.faceLabels === undefined ? {} : { faceLabels: spec.faceLabels }),
311
+ body,
312
+ detector: new SettlingDetector(this.#settling),
313
+ previous: state,
314
+ current: state,
315
+ };
316
+ dice.push(die);
317
+ this.#renderer.createDie(toRenderState(die));
318
+ body.applyImpulse(generated.impulse, generated.torqueImpulse);
319
+ }
320
+ return dice;
321
+ }
322
+ catch (error) {
323
+ for (const die of dice) {
324
+ this.#physics.removeDie(die.id);
325
+ this.#renderer.removeDie(die.id);
326
+ }
327
+ throw error;
328
+ }
329
+ }
330
+ #createPhysicalSpecs(task) {
331
+ const specs = [];
332
+ let groupIndex = 0;
333
+ for (const expression of task.parsed.expressions) {
334
+ if (expression.kind === 'modifier')
335
+ continue;
336
+ if (expression.kind === 'dice') {
337
+ const type = `d${expression.sides}`;
338
+ if (!isDieType(type))
339
+ throw new RangeError(`${type} is not a standard die type`);
340
+ for (let count = 0; count < expression.count; count += 1) {
341
+ specs.push({ type, geometryType: type });
342
+ }
343
+ continue;
344
+ }
345
+ for (let count = 0; count < expression.count; count += 1) {
346
+ const groupId = `${task.session.id}:group-${groupIndex++}`;
347
+ if (expression.type === 'd100') {
348
+ specs.push({
349
+ type: 'd100',
350
+ geometryType: 'd10',
351
+ component: { groupId, groupType: 'd100', role: 'tens' },
352
+ faceLabels: D100_TENS_LABELS,
353
+ });
354
+ specs.push({
355
+ type: 'd10',
356
+ geometryType: 'd10',
357
+ component: { groupId, groupType: 'd100', role: 'units' },
358
+ });
359
+ continue;
360
+ }
361
+ specs.push({
362
+ type: 'd6',
363
+ geometryType: 'd6',
364
+ component: { groupId, groupType: 'd66', role: 'tens' },
365
+ faceLabels: D66_TENS_LABELS,
366
+ });
367
+ specs.push({
368
+ type: 'd6',
369
+ geometryType: 'd6',
370
+ component: { groupId, groupType: 'd66', role: 'units' },
371
+ });
372
+ }
373
+ }
374
+ return specs;
375
+ }
376
+ #placeDie(generated, index, total) {
377
+ if (total <= 4)
378
+ return generated;
379
+ const columns = Math.ceil(Math.sqrt((total * this.#tray.width) / this.#tray.depth));
380
+ const rows = Math.ceil(total / columns);
381
+ const column = index % columns;
382
+ const row = Math.floor(index / columns);
383
+ const cellWidth = (this.#tray.width - 1) / columns;
384
+ const cellDepth = (this.#tray.depth - 1) / rows;
385
+ return {
386
+ x: (column - (columns - 1) / 2) * cellWidth + generated.x * 0.03,
387
+ y: generated.y,
388
+ z: (row - (rows - 1) / 2) * cellDepth + generated.z * 0.03,
389
+ };
390
+ }
391
+ #scheduleFrame() {
392
+ if (this.#active === undefined || this.#frameToken !== undefined)
393
+ return;
394
+ this.#frameToken = this.#scheduler.request((timestampMs) => {
395
+ this.#frameToken = undefined;
396
+ this.#runFrame(timestampMs);
397
+ });
398
+ }
399
+ #runFrame(timestampMs) {
400
+ const active = this.#active;
401
+ if (active === undefined)
402
+ return;
403
+ try {
404
+ const frameDelta = Math.max(0, Math.min((timestampMs - this.#lastFrameMs) / 1_000, this.#maxFrameDeltaSeconds));
405
+ this.#lastFrameMs = timestampMs;
406
+ this.#accumulatorSeconds += frameDelta;
407
+ while (this.#accumulatorSeconds >= this.#fixedStepSeconds) {
408
+ for (const die of active.dice)
409
+ die.previous = die.current;
410
+ this.#physics.step(this.#fixedStepSeconds);
411
+ this.#accumulatorSeconds -= this.#fixedStepSeconds;
412
+ for (const die of active.dice) {
413
+ die.current = die.body.getState();
414
+ if (die.result !== undefined)
415
+ continue;
416
+ const settling = die.detector.update(die.current, this.#fixedStepSeconds * 1_000);
417
+ if (settling === 'timed-out')
418
+ throw new RollTimeoutError(active.task.session.id);
419
+ if (settling === 'settled') {
420
+ const geometry = getDieGeometry(die.geometryType);
421
+ const faceValue = resolveFace(geometry, die.current.quaternion);
422
+ die.result = this.#createDieResult(die, faceValue);
423
+ this.emit('die:settled', { sessionId: active.task.session.id, die: die.result });
424
+ }
425
+ }
426
+ }
427
+ for (const die of active.dice)
428
+ this.#renderer.updateDie(toRenderState(die));
429
+ const allSettled = active.dice.every((die) => die.result !== undefined);
430
+ this.#renderer.render(allSettled ? 1 : this.#accumulatorSeconds / this.#fixedStepSeconds);
431
+ if (allSettled) {
432
+ this.#completeActive(active);
433
+ return;
434
+ }
435
+ this.#scheduleFrame();
436
+ }
437
+ catch (error) {
438
+ this.#failActive(active, error);
439
+ }
440
+ }
441
+ #createDieResult(die, faceValue) {
442
+ if (die.component === undefined) {
443
+ if (die.type === 'd100')
444
+ throw new Error('A d100 result requires percentile component data');
445
+ return Object.freeze({ id: die.id, type: die.type, value: faceValue });
446
+ }
447
+ const { groupId, groupType, role } = die.component;
448
+ const digit = groupType === 'd100' ? faceValue % 10 : faceValue;
449
+ return Object.freeze({
450
+ id: die.id,
451
+ type: die.type,
452
+ value: role === 'tens' ? digit * 10 : digit,
453
+ component: Object.freeze({ groupId, groupType, role, faceValue }),
454
+ });
455
+ }
456
+ #completeActive(active) {
457
+ const session = active.task.session;
458
+ session.state = 'settled';
459
+ session.completedAt = this.#now();
460
+ if (session.startedAt === undefined)
461
+ throw new Error('Active roll has no start time');
462
+ const diceResults = active.dice.map((die) => {
463
+ if (die.result === undefined)
464
+ throw new Error(`Die ${die.id} has no settled result`);
465
+ return die.result;
466
+ });
467
+ const result = createRollResult({
468
+ id: session.id,
469
+ notation: session.notation,
470
+ dice: diceResults,
471
+ modifier: getNotationModifier(active.task.parsed),
472
+ startedAt: session.startedAt,
473
+ completedAt: session.completedAt,
474
+ });
475
+ for (const die of active.dice)
476
+ this.#displayedDieIds.add(die.id);
477
+ this.#active = undefined;
478
+ this.#detachAbort(active.task);
479
+ active.task.resolve(result);
480
+ this.emit('roll:complete', result);
481
+ this.#startNext();
482
+ }
483
+ #cancelActive(task) {
484
+ this.#frameToken?.cancel();
485
+ this.#frameToken = undefined;
486
+ const active = this.#active;
487
+ this.#active = undefined;
488
+ if (active !== undefined)
489
+ this.#removeDice(active.dice);
490
+ this.#rejectCancelled(task);
491
+ this.#startNext();
492
+ }
493
+ #rejectCancelled(task) {
494
+ task.session.state = 'cancelled';
495
+ task.session.completedAt = this.#now();
496
+ this.#detachAbort(task);
497
+ task.reject(new RollCancelledError(task.session.id));
498
+ this.emit('roll:cancel', snapshotSession(task.session));
499
+ }
500
+ #failActive(active, error) {
501
+ this.#active = undefined;
502
+ this.#removeDice(active.dice);
503
+ this.#failTask(active.task, error);
504
+ }
505
+ #failTask(task, error) {
506
+ task.session.state = 'failed';
507
+ task.session.completedAt = this.#now();
508
+ this.#detachAbort(task);
509
+ task.reject(error);
510
+ this.emit('error', { session: snapshotSession(task.session), error });
511
+ this.#startNext();
512
+ }
513
+ #removeDice(dice) {
514
+ for (const die of dice) {
515
+ this.#physics.removeDie(die.id);
516
+ this.#renderer.removeDie(die.id);
517
+ }
518
+ }
519
+ #removeDisplayedDice() {
520
+ for (const id of this.#displayedDieIds) {
521
+ this.#physics.removeDie(id);
522
+ this.#renderer.removeDie(id);
523
+ }
524
+ this.#displayedDieIds.clear();
525
+ }
526
+ #detachAbort(task) {
527
+ if (task.signal !== undefined && task.abortListener !== undefined) {
528
+ task.signal.removeEventListener('abort', task.abortListener);
529
+ }
530
+ }
531
+ #assertSupportedAndWithinLimits(parsed) {
532
+ let logicalDice = 0;
533
+ let physicalDice = 0;
534
+ for (const expression of parsed.expressions) {
535
+ if (expression.kind === 'modifier')
536
+ continue;
537
+ if (expression.kind === 'dice') {
538
+ const type = `d${expression.sides}`;
539
+ if (!isDieType(type) || !hasDieGeometry(type)) {
540
+ throw new RangeError(`${type} is not supported by the current engine`);
541
+ }
542
+ }
543
+ logicalDice = this.#addWithinLimit(logicalDice, expression.count, 'logical-dice', this.#limits.maxLogicalDice);
544
+ physicalDice = this.#addWeightedWithinLimit(physicalDice, expression.count, expression.kind === 'paired-dice' ? 2 : 1, 'physical-dice', this.#limits.maxPhysicalDice);
545
+ }
546
+ }
547
+ #addWithinLimit(current, increment, limit, maximum) {
548
+ if (increment > maximum - current) {
549
+ throw new RollLimitExceededError(limit, maximum, current + increment);
550
+ }
551
+ return current + increment;
552
+ }
553
+ #addWeightedWithinLimit(current, count, weight, limit, maximum) {
554
+ if (count > Math.floor((maximum - current) / weight)) {
555
+ throw new RollLimitExceededError(limit, maximum, current + count * weight);
556
+ }
557
+ return current + count * weight;
558
+ }
559
+ #mergeTheme(theme) {
560
+ const merged = Object.freeze({ ...DEFAULT_THEME, ...theme });
561
+ if (merged.bodyColor.length === 0 || merged.labelColor.length === 0) {
562
+ throw new RangeError('Theme colors must not be empty');
563
+ }
564
+ for (const [name, value] of [
565
+ ['roughness', merged.roughness],
566
+ ['metalness', merged.metalness],
567
+ ]) {
568
+ if (!Number.isFinite(value) || value < 0 || value > 1) {
569
+ throw new RangeError(`Theme ${name} must be a finite number in [0, 1]`);
570
+ }
571
+ }
572
+ return merged;
573
+ }
574
+ #assertReady() {
575
+ this.#assertAlive();
576
+ if (!this.#initialized)
577
+ throw new Error('DiceEngine has not been initialized');
578
+ }
579
+ #assertAlive() {
580
+ if (this.#destroyed)
581
+ throw new DiceEngineDestroyedError();
582
+ }
583
+ }
@@ -0,0 +1,18 @@
1
+ export declare class RollCancelledError extends Error {
2
+ readonly sessionId: string;
3
+ constructor(sessionId: string);
4
+ }
5
+ export declare class RollTimeoutError extends Error {
6
+ readonly sessionId: string;
7
+ constructor(sessionId: string);
8
+ }
9
+ export declare class DiceEngineDestroyedError extends Error {
10
+ constructor();
11
+ }
12
+ export type RollLimit = 'notation-length' | 'logical-dice' | 'physical-dice' | 'queue-size';
13
+ export declare class RollLimitExceededError extends RangeError {
14
+ readonly limit: RollLimit;
15
+ readonly maximum: number;
16
+ readonly actual: number;
17
+ constructor(limit: RollLimit, maximum: number, actual: number);
18
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,34 @@
1
+ export class RollCancelledError extends Error {
2
+ sessionId;
3
+ constructor(sessionId) {
4
+ super(`Roll ${sessionId} was cancelled`);
5
+ this.name = 'RollCancelledError';
6
+ this.sessionId = sessionId;
7
+ }
8
+ }
9
+ export class RollTimeoutError extends Error {
10
+ sessionId;
11
+ constructor(sessionId) {
12
+ super(`Roll ${sessionId} did not settle before the timeout`);
13
+ this.name = 'RollTimeoutError';
14
+ this.sessionId = sessionId;
15
+ }
16
+ }
17
+ export class DiceEngineDestroyedError extends Error {
18
+ constructor() {
19
+ super('DiceEngine has been destroyed');
20
+ this.name = 'DiceEngineDestroyedError';
21
+ }
22
+ }
23
+ export class RollLimitExceededError extends RangeError {
24
+ limit;
25
+ maximum;
26
+ actual;
27
+ constructor(limit, maximum, actual) {
28
+ super(`Roll exceeds ${limit} limit of ${maximum} (received ${actual})`);
29
+ this.name = 'RollLimitExceededError';
30
+ this.limit = limit;
31
+ this.maximum = maximum;
32
+ this.actual = actual;
33
+ }
34
+ }
@@ -0,0 +1,4 @@
1
+ export { DiceEngine } from './dice-engine.js';
2
+ export { DiceEngineDestroyedError, RollCancelledError, RollLimitExceededError, RollTimeoutError, } from './errors.js';
3
+ export type { RollLimit } from './errors.js';
4
+ export type { DiceEngineEvents, DiceEngineFacade, DiceEngineLimits, DiceEngineOptions, DiceMaterialType, DiceTheme, FrameScheduler, FrameToken, RollOptions, } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { DiceEngine } from './dice-engine.js';
2
+ export { DiceEngineDestroyedError, RollCancelledError, RollLimitExceededError, RollTimeoutError, } from './errors.js';
@@ -0,0 +1,59 @@
1
+ import type { DieResult, RandomSource, RollMode, RollResult, RollSession } from '@dice-o-rolla/dice-core';
2
+ import type { DicePhysicsMaterial, PhysicsWorld, SettlingOptions, ThrowGeneratorOptions, TrayOptions } from '@dice-o-rolla/dice-physics';
3
+ import type { DiceRenderer, RendererTheme, RendererViewport } from '@dice-o-rolla/dice-renderer';
4
+ export interface FrameToken {
5
+ cancel(): void;
6
+ }
7
+ export interface FrameScheduler {
8
+ request(callback: (timestampMs: number) => void): FrameToken;
9
+ }
10
+ export type DiceMaterialType = RendererTheme['material'];
11
+ export type DiceTheme = RendererTheme;
12
+ export interface RollOptions {
13
+ readonly mode?: RollMode;
14
+ readonly signal?: AbortSignal;
15
+ }
16
+ export interface DiceEngineLimits {
17
+ readonly maxNotationLength: number;
18
+ readonly maxLogicalDice: number;
19
+ readonly maxPhysicalDice: number;
20
+ readonly maxQueuedRolls: number;
21
+ }
22
+ export interface DiceEngineEvents {
23
+ readonly 'roll:start': RollSession;
24
+ readonly 'die:settled': {
25
+ readonly sessionId: string;
26
+ readonly die: DieResult;
27
+ };
28
+ readonly 'roll:complete': RollResult;
29
+ readonly 'roll:cancel': RollSession;
30
+ readonly 'theme:change': DiceTheme;
31
+ readonly error: {
32
+ readonly session: RollSession;
33
+ readonly error: unknown;
34
+ };
35
+ }
36
+ export interface DiceEngineOptions {
37
+ readonly physics: PhysicsWorld;
38
+ readonly renderer: DiceRenderer;
39
+ readonly random?: RandomSource;
40
+ readonly scheduler?: FrameScheduler;
41
+ readonly now?: () => number;
42
+ readonly fixedStepSeconds?: number;
43
+ readonly maxFrameDeltaSeconds?: number;
44
+ readonly settling?: SettlingOptions;
45
+ readonly throw?: ThrowGeneratorOptions;
46
+ readonly tray?: TrayOptions;
47
+ readonly diceMaterial?: DicePhysicsMaterial;
48
+ readonly theme?: Partial<DiceTheme>;
49
+ readonly limits?: Partial<DiceEngineLimits>;
50
+ }
51
+ export interface DiceEngineFacade {
52
+ initialize(): Promise<void>;
53
+ roll(notation: string, options?: RollOptions): Promise<RollResult>;
54
+ cancel(sessionId?: string): boolean;
55
+ clear(): void;
56
+ resize(viewport: RendererViewport): void;
57
+ setTheme(theme: Partial<DiceTheme>): DiceTheme;
58
+ destroy(): void;
59
+ }
package/dist/types.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@dice-o-rolla/dice-engine",
3
+ "version": "0.1.0",
4
+ "description": "Framework-neutral physical dice engine with Rapier and Three.js browser adapters.",
5
+ "keywords": [
6
+ "dice",
7
+ "dice-roller",
8
+ "physics",
9
+ "rpg",
10
+ "three.js",
11
+ "typescript"
12
+ ],
13
+ "license": "Apache-2.0",
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE",
18
+ "NOTICE",
19
+ "THIRD_PARTY_NOTICES.md"
20
+ ],
21
+ "type": "module",
22
+ "sideEffects": false,
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
29
+ },
30
+ "./browser": {
31
+ "types": "./dist/browser.d.ts",
32
+ "import": "./dist/browser.js",
33
+ "default": "./dist/browser.js"
34
+ }
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "registry": "https://registry.npmjs.org/"
39
+ },
40
+ "dependencies": {
41
+ "@dice-o-rolla/dice-core": "0.1.0",
42
+ "@dice-o-rolla/dice-geometry": "0.1.0",
43
+ "@dice-o-rolla/dice-physics": "0.1.0",
44
+ "@dice-o-rolla/dice-physics-rapier": "0.1.0",
45
+ "@dice-o-rolla/dice-renderer": "0.1.0",
46
+ "@dice-o-rolla/dice-renderer-three": "0.1.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=20.0.0"
50
+ }
51
+ }