@hology/core 0.0.182 → 0.0.183
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as s}from"./actors/factory.js";import{World as n}from"./services/world.js";import{SceneMaterializer as
|
|
1
|
+
import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as s}from"./actors/factory.js";import{World as n}from"./services/world.js";import{SceneMaterializer as o}from"../scene/materializer.js";import{ViewController as r}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{builtInComponents as m}from"./actors/builtin/components/index.js";import{activeContainerInstance as d}from"./actors/internal/container-map.js";import{InputService as l}from"./input/index.js";import{RuntimeAssetsService as p}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as h}from"../scene/asset-resource-loader.js";import{AssetLoader as f}from"./services/asset-loader.js";import{polyfillClient as u}from"./polyfill.js";import{Subject as g}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as j}from"../scene/runtime-bundled-backend-service.js";import{Scene as b}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";import{AssetsProvider as y}from"../scene/assets-provider.js";export function initiateGame(l,g){if(u(),0!=g.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(r);const I=e.of("default"),x=new HologyRuntime(I),D=new s(I,{inEditor:!1});var R;e.set(s,D),R=g.element,Object.assign(R.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const A=new i(g.element,{enableXR:!0===g.xr?.enabled,maxPixelRatio:g.rendering?.maxPixelRatio,resolutionScale:g.rendering?.resolutionScale,bloom:{enabled:!1!==g?.rendering?.bloom?.enabled},reflection:{enabled:!1!==g?.rendering?.reflection?.enabled},shadows:{cascadeUpdateIntervals:[22,135,250,500]}});A.renderer.shadowMap.enabled=g.rendering?.shadows?.enabled??!0,A.renderer.shadowMap.autoUpdate=g.rendering?.shadows?.autoUpdate??!0,A.renderer.debug.checkShaderErrors=!1,e.set(i,A);const G=new r(A);e.set(r,G);const O=new j,P=new p(O),z=new h;z.setDataDir(g.dataDir),z.initKtx2(A.renderer);const E=Object.entries(g.shaders).map(([e,t])=>({name:e,type:t})),H=Object.entries(g.actors).map(([e,t])=>({name:e,type:t})),M={...m,...g.components??{}},U=Object.entries(M).map(([e,t])=>({name:e,type:t})),W=new v(E);e.set(v,W);const k=new f(z,P,E);e.set(y,P),e.set(h,z),e.set(f,k);const F=new b,N=new o(F,new S,P,z,A,E,H,D,U);e.set(o,N);const T=e.get(n);return e.set(n,T),T.materializer=N,(async()=>{const s=e.get(a);if(await s.start(),x.isShutdown)return;if(await O.preloadData(),x.isShutdown)return;T.scene=F;const{scene:n,actors:o}=await t(A,g.sceneName,g.dataDir,g.shaders,g.actors,M,D,O,P,z,{detailTier:g.detailTier});T.scene=n,s.scene=T.scene;for(const e of F.children)T.scene.add(e);if(x.isShutdown)return void A.stop();e.import([c]);for(const e of o)T.addActor(e);s.addFromScene(n),console.log("Start compile shaders"),console.time("compile shaders"),await A.compileAsync(),console.timeEnd("compile shaders"),console.log("Finished compile shaders. Programs: ",A.renderer.info.programs?.length??0),A.loop(e=>{}),x.status=5,x.shutdownStarted.subscribe(()=>{z.disposeAll()}),d.value=I,I.remove(l),I.set({id:l,type:l});const r=I.get(l);d.value=null,x.gameInstance=r,I.get(w).start(),r instanceof GameInstance&&await r.onStart(),x._resolver(!0)})(),x}export class GameInstance{onStart(){}onShutdown(){}}export function createHologyScene(){}export class HologyRuntime{constructor(e){this.containerInstance=e,this.status=0,this.isShutdown=!1,this.shutdownStarted=new g,this.ready=new Promise(e=>{this._resolver=e})}getWorld(){return this.containerInstance.get(n)}getService(e){return this.containerInstance.get(e)}shutdown(){this.isShutdown=!0;const e=this.shutdownStarted;e.next(),e.complete(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(l).stop();const t=this.containerInstance.get(i);t?.stop();const s=this.containerInstance.get(r);s.setMuted(!0),s.dispose();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(o).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
|
|
2
2
|
* Copyright (©) 2025 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContainerInstance } from 'typedi';
|
|
2
|
+
type Constructable<T> = abstract new (...args: any[]) => T;
|
|
2
3
|
export declare function inject<T>(type: Constructable<T>): T;
|
|
3
4
|
export declare function withInjectionContext<T>(containerInstance: ContainerInstance, fn: (diContainer: ContainerInstance) => T): T;
|
|
5
|
+
export {};
|
|
4
6
|
//# sourceMappingURL=inject.d.ts.map
|