nova64 0.2.1

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +786 -0
  3. package/index.html +651 -0
  4. package/package.json +255 -0
  5. package/public/os9-shell/assets/index-B1Uvacma.js +32825 -0
  6. package/public/os9-shell/assets/index-B1Uvacma.js.map +1 -0
  7. package/public/os9-shell/assets/index-DIHfrTaW.css +1 -0
  8. package/public/os9-shell/index.html +14 -0
  9. package/public/os9-shell/nova-icon.svg +12 -0
  10. package/runtime/api-2d.js +878 -0
  11. package/runtime/api-3d/camera.js +73 -0
  12. package/runtime/api-3d/instancing.js +180 -0
  13. package/runtime/api-3d/lights.js +51 -0
  14. package/runtime/api-3d/materials.js +47 -0
  15. package/runtime/api-3d/models.js +84 -0
  16. package/runtime/api-3d/pbr.js +69 -0
  17. package/runtime/api-3d/primitives.js +304 -0
  18. package/runtime/api-3d/scene.js +169 -0
  19. package/runtime/api-3d/transforms.js +161 -0
  20. package/runtime/api-3d.js +154 -0
  21. package/runtime/api-effects.js +753 -0
  22. package/runtime/api-presets.js +85 -0
  23. package/runtime/api-skybox.js +178 -0
  24. package/runtime/api-sprites.js +100 -0
  25. package/runtime/api-voxel.js +601 -0
  26. package/runtime/api.js +201 -0
  27. package/runtime/assets.js +27 -0
  28. package/runtime/audio.js +114 -0
  29. package/runtime/collision.js +47 -0
  30. package/runtime/console.js +101 -0
  31. package/runtime/editor.js +233 -0
  32. package/runtime/font.js +233 -0
  33. package/runtime/framebuffer.js +28 -0
  34. package/runtime/fullscreen-button.js +185 -0
  35. package/runtime/gpu-canvas2d.js +47 -0
  36. package/runtime/gpu-threejs.js +639 -0
  37. package/runtime/gpu-webgl2.js +310 -0
  38. package/runtime/index.js +22 -0
  39. package/runtime/input.js +225 -0
  40. package/runtime/logger.js +60 -0
  41. package/runtime/physics.js +101 -0
  42. package/runtime/screens.js +213 -0
  43. package/runtime/storage.js +38 -0
  44. package/runtime/store.js +151 -0
  45. package/runtime/textinput.js +68 -0
  46. package/runtime/ui/buttons.js +124 -0
  47. package/runtime/ui/panels.js +105 -0
  48. package/runtime/ui/text.js +86 -0
  49. package/runtime/ui/widgets.js +141 -0
  50. package/runtime/ui.js +111 -0
  51. package/src/main.js +474 -0
  52. package/vite.config.js +63 -0
@@ -0,0 +1,154 @@
1
+ // runtime/api-3d.js
2
+ // Thin orchestrator — delegates to runtime/api-3d/*.js sub-modules
3
+ import * as THREE from 'three';
4
+ globalThis.THREE = THREE;
5
+ import { materialsModule } from './api-3d/materials.js';
6
+ import { primitivesModule } from './api-3d/primitives.js';
7
+ import { transformsModule } from './api-3d/transforms.js';
8
+ import { cameraModule } from './api-3d/camera.js';
9
+ import { lightsModule } from './api-3d/lights.js';
10
+ import { modelsModule } from './api-3d/models.js';
11
+ import { instancingModule } from './api-3d/instancing.js';
12
+ import { pbrModule } from './api-3d/pbr.js';
13
+ import { sceneModule } from './api-3d/scene.js';
14
+
15
+ export function threeDApi(gpu) {
16
+ if (!gpu.getScene) return { exposeTo: () => {} };
17
+
18
+ const scene = gpu.getScene();
19
+ const camera = gpu.getCamera();
20
+ const renderer = gpu.getRenderer();
21
+
22
+ // Shared state — passed by reference into every sub-module
23
+ const meshes = new Map();
24
+ const mixers = new Map();
25
+ const modelAnimations = new Map();
26
+ const materialCache = new Map();
27
+ const cartLights = new Map();
28
+ const instancedMeshes = new Map();
29
+ const lodObjects = new Map();
30
+ const counters = { mesh: 0, light: 0, instance: 0, lod: 0 };
31
+
32
+ // Build context — each module appends its exports so later modules can call earlier ones
33
+ const ctx = {
34
+ scene,
35
+ camera,
36
+ renderer,
37
+ gpu,
38
+ meshes,
39
+ mixers,
40
+ modelAnimations,
41
+ materialCache,
42
+ cartLights,
43
+ instancedMeshes,
44
+ lodObjects,
45
+ counters,
46
+ };
47
+
48
+ Object.assign(ctx, materialsModule(ctx));
49
+ Object.assign(ctx, primitivesModule(ctx));
50
+ Object.assign(ctx, transformsModule(ctx));
51
+ Object.assign(ctx, cameraModule(ctx));
52
+ Object.assign(ctx, lightsModule(ctx));
53
+ Object.assign(ctx, modelsModule(ctx));
54
+ Object.assign(ctx, instancingModule(ctx));
55
+ Object.assign(ctx, pbrModule(ctx));
56
+ Object.assign(ctx, sceneModule(ctx)); // last: uses late binding to call other modules
57
+
58
+ return {
59
+ exposeTo(target) {
60
+ Object.assign(target, {
61
+ // Primitive creation
62
+ createCube: ctx.createCube,
63
+ createSphere: ctx.createSphere,
64
+ createCylinder: ctx.createCylinder,
65
+ createPlane: ctx.createPlane,
66
+ createAdvancedCube: ctx.createAdvancedCube,
67
+ createAdvancedSphere: ctx.createAdvancedSphere,
68
+ createTorus: ctx.createTorus,
69
+ createCone: ctx.createCone,
70
+ createCapsule: ctx.createCapsule,
71
+
72
+ // Mesh management
73
+ destroyMesh: ctx.destroyMesh,
74
+ removeMesh: ctx.removeMesh,
75
+
76
+ // Model and texture loading
77
+ loadModel: ctx.loadModel,
78
+ playAnimation: ctx.playAnimation,
79
+ updateAnimations: ctx.updateAnimations,
80
+ loadTexture: ctx.loadTexture,
81
+
82
+ // Transforms
83
+ setPosition: ctx.setPosition,
84
+ setRotation: ctx.setRotation,
85
+ setScale: ctx.setScale,
86
+ getPosition: ctx.getPosition,
87
+ getRotation: ctx.getRotation,
88
+ rotateMesh: ctx.rotateMesh,
89
+ moveMesh: ctx.moveMesh,
90
+
91
+ // Mesh helpers
92
+ setFlatShading: ctx.setFlatShading,
93
+ setMeshVisible: ctx.setMeshVisible,
94
+ setMeshOpacity: ctx.setMeshOpacity,
95
+ setCastShadow: ctx.setCastShadow,
96
+ setReceiveShadow: ctx.setReceiveShadow,
97
+
98
+ // Camera
99
+ setCameraPosition: ctx.setCameraPosition,
100
+ setCameraTarget: ctx.setCameraTarget,
101
+ setCameraLookAt: ctx.setCameraLookAt,
102
+ setCameraFOV: ctx.setCameraFOV,
103
+
104
+ // Scene / atmosphere
105
+ setFog: ctx.setFog,
106
+ clearFog: ctx.clearFog,
107
+ setLightDirection: ctx.setLightDirection,
108
+ setLightColor: ctx.setLightColor,
109
+ setAmbientLight: ctx.setAmbientLight,
110
+ setDirectionalLight: ctx.setDirectionalLight,
111
+ clearScene: ctx.clearScene,
112
+
113
+ // Effects
114
+ enablePixelation: ctx.enablePixelation,
115
+ enableDithering: ctx.enableDithering,
116
+
117
+ // Dynamic lights
118
+ createPointLight: ctx.createPointLight,
119
+ setPointLightPosition: ctx.setPointLightPosition,
120
+ setPointLightColor: ctx.setPointLightColor,
121
+ removeLight: ctx.removeLight,
122
+
123
+ // GPU instancing
124
+ createInstancedMesh: ctx.createInstancedMesh,
125
+ setInstanceTransform: ctx.setInstanceTransform,
126
+ setInstanceColor: ctx.setInstanceColor,
127
+ finalizeInstances: ctx.finalizeInstances,
128
+ removeInstancedMesh: ctx.removeInstancedMesh,
129
+
130
+ // LOD system
131
+ createLODMesh: ctx.createLODMesh,
132
+ setLODPosition: ctx.setLODPosition,
133
+ removeLODMesh: ctx.removeLODMesh,
134
+ updateLODs: ctx.updateLODs,
135
+
136
+ // Normal / PBR maps
137
+ loadNormalMap: ctx.loadNormalMap,
138
+ setNormalMap: ctx.setNormalMap,
139
+ setPBRMaps: ctx.setPBRMaps,
140
+
141
+ // Interaction / stats / convenience
142
+ raycastFromCamera: ctx.raycastFromCamera,
143
+ get3DStats: ctx.get3DStats,
144
+ setupScene: ctx.setupScene,
145
+
146
+ // Direct Three.js access for advanced users
147
+ getScene: () => scene,
148
+ getCamera: () => camera,
149
+ getRenderer: () => renderer,
150
+ getMesh: ctx.getMesh,
151
+ });
152
+ },
153
+ };
154
+ }