@soonspacejs/plugin-soonbuilder-loader 2.5.46
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/README.md +5 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.esm.js +15 -0
- package/package.json +17 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import SoonSpace from 'soonspacejs';
|
|
2
|
+
import { ModelInfo } from 'soonspacejs/types/Library';
|
|
3
|
+
export interface TModelInfo extends ModelInfo {
|
|
4
|
+
children?: TModelInfo[];
|
|
5
|
+
}
|
|
6
|
+
export default class SoonbuilderLoaderPlugin {
|
|
7
|
+
readonly ssp: SoonSpace;
|
|
8
|
+
fileInfo: any;
|
|
9
|
+
sceneInfo: any;
|
|
10
|
+
treeData: TModelInfo[];
|
|
11
|
+
modelData: ModelInfo[];
|
|
12
|
+
constructor(ssp: SoonSpace);
|
|
13
|
+
load(path: string): Promise<void>;
|
|
14
|
+
private _pushModelData;
|
|
15
|
+
private _text2IVector3;
|
|
16
|
+
private _text2Bool;
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*! *****************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
function t(t,e,i,o){return new(i||(i=Promise))((function(s,n){function l(t){try{r(o.next(t))}catch(t){n(t)}}function a(t){try{r(o.throw(t))}catch(t){n(t)}}function r(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(l,a)}r((o=o.apply(t,e||[])).next())}))}class e{constructor(t){this.ssp=t,this.treeData=[],this.modelData=[]}load(e){var i;return t(this,void 0,void 0,(function*(){const{xmlToJson:t}=this.ssp.utils;this.fileInfo=yield t(`${e}/FileInfo.xml`);const o=this.fileInfo.folder._attributes.name;this.sceneInfo=yield t(`${e}/${o}.xml`);const{Project:{Building:{Floors:s,SpaceInfo:n,ObjectHierarchy:l}}}=this.sceneInfo;for(let t=0;t<s.Floor.length;t++){const{_attributes:o,FileSource:n}=s.Floor[t],{id:a,name:r}=o,{name:u}=n._attributes,c={id:a,name:r,url:`${e}${u}`,children:[],userData:s.Floor[t]};this._pushModelData(c);const h=yield this.ssp.loadModel(c);if(!h)continue;const d=l.Entity.find((({_attributes:{id:t,type:e}})=>"Floor"===e&&t===a)).Entity.filter((({_attributes:{type:t}})=>"FACILITY"===t));for(let t=0;t<d.length;t++){const{id:o,name:s,longname:n,visible:l,position:a,eular:r,scale:u}=d[t]._attributes,f={id:o,name:s,url:`${e}/${n}.sbm`,visible:this._text2Bool(l),position:this._text2IVector3(a),rotation:this._text2IVector3(r),scale:this._text2IVector3(u),userData:d[t]},p=yield this.ssp.loadModel(f);p&&(this.ssp.addObject(p,h),this._pushModelData(f),null===(i=c.children)||void 0===i||i.push(f))}this.treeData.push(c)}}))}_pushModelData(t){this.modelData.find((({id:e})=>e===t.id))||this.modelData.push(t)}_text2IVector3(t){const e=t.split(", ");return{x:Number(e[0]),y:Number(e[1]),z:Number(e[2])}}_text2Bool(t){return"True"===t}}export{e as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@soonspacejs/plugin-soonbuilder-loader",
|
|
3
|
+
"pluginName": "SoonbuilderLoaderPlugin",
|
|
4
|
+
"version": "2.5.46",
|
|
5
|
+
"description": "soonbuilder-loader plugin for SoonSpace.js",
|
|
6
|
+
"main": "dist/index.esm.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"unpkg": "dist/index.esm.js",
|
|
9
|
+
"typings": "dist/index.d.ts",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"soonspacejs",
|
|
12
|
+
"soonbuilder-loader"
|
|
13
|
+
],
|
|
14
|
+
"author": "xuek",
|
|
15
|
+
"license": "UNLICENSED",
|
|
16
|
+
"gitHead": "eb50100af1f670ed940114186bd9cdeaef6ec5c1"
|
|
17
|
+
}
|