NREL / floorspace.js

Other
66 stars 35 forks source link

Embedded 3D Previewer #402

Closed benfen closed 2 years ago

benfen commented 2 years ago

Resolves https://github.com/NREL/floorspace.js/issues/282

Port logic from https://github.com/macumber/emscripten-test to add a 3D previewer to floorspace.js. Adds an option to the Save Floorplan button to export to threeJS JSON instead; also adds a button to the top left to directly open the current floorspace in three.js.

The majority of the cpp files here are pulled from openstudio.

The PR is deployed at: https://benfen.github.io/floorspace.js/

macumber commented 2 years ago

It looks like the WASM doesn't end up in the embeddable_geometry_editor.html which the OS App uses which is good for me. I'll check that the embedded build still works in a day or two.

macumber commented 2 years ago

npm run openstudio-build is failing for me after these latest commits

macumber@Automatic-Magic-PC MINGW64 /c/repos/floorspace.js (feat/embedded-previewer)
$ npm run openstudio-build

> floorspace.js@0.7.0 openstudio-build C:\repos\floorspace.js
> node build/build.js && node build/build-embeddable.js

  Tip:
  Built files are meant to be served over an HTTP server.
  Opening index.html over file:// won't work.

cp: no such file or directory: static/*
Hash: 845ba641053087b2cfb2
Version: webpack 1.15.0
Time: 25227ms
                                                     Asset       Size  Chunks             Chunk Names
                    static/fonts/element-icons.6f0a763.ttf      11 kB          [emitted]
                static/js/manifest.9fa52e0d6e84e9c8767c.js  902 bytes       0  [emitted]  manifest
                  static/js/vendor.c53abce85da2e193422d.js    1.75 MB    1, 0  [emitted]  vendor
                     static/js/app.77b89bc4e5afd7b432ae.js     286 kB    2, 0  [emitted]  app
                  static/js/viewer.72749e8e1a4421521267.js    20.5 kB    3, 0  [emitted]  viewer
       static/css/app.e034f7014dba0322645c4385deb681d3.css     224 kB    2, 0  [emitted]  app
    static/css/viewer.fd865ab4ed6f1814413a2a2a3b80d400.css  859 bytes    3, 0  [emitted]  viewer
            static/js/manifest.9fa52e0d6e84e9c8767c.js.map    9.21 kB       0  [emitted]  manifest
              static/js/vendor.c53abce85da2e193422d.js.map    10.8 MB    1, 0  [emitted]  vendor
                 static/js/app.77b89bc4e5afd7b432ae.js.map     1.5 MB    2, 0  [emitted]  app
   static/css/app.e034f7014dba0322645c4385deb681d3.css.map     297 kB    2, 0  [emitted]  app
              static/js/viewer.72749e8e1a4421521267.js.map     115 kB    3, 0  [emitted]  viewer
static/css/viewer.fd865ab4ed6f1814413a2a2a3b80d400.css.map    1.69 kB    3, 0  [emitted]  viewer
                                                index.html    1.11 kB          [emitted]
                                       3DViewer\index.html    1.27 kB          [emitted]
Loading scripts from: 3DViewer/libtest_lib.js

internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open './dist3DViewer/libtest_lib.js'
    at Object.openSync (fs.js:462:3)
    at readFileSync (fs.js:364:35)
    at C:\repos\floorspace.js\build\build-embeddable.js:10:10
    at Array.map (<anonymous>)
    at Object.<anonymous> (C:\repos\floorspace.js\build\build-embeddable.js:7:55)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: './dist3DViewer/libtest_lib.js'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! floorspace.js@0.7.0 openstudio-build: `node build/build.js && node build/build-embeddable.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the floorspace.js@0.7.0 openstudio-build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\macumber\AppData\Roaming\npm-cache\_logs\2021-08-05T18_39_46_486Z-debug.log

2021-08-05T18_39_46_486Z-debug.log

macumber commented 2 years ago

I'll try to add your changes to the previewer to https://github.com/NREL/openstudio-common-measures-gem/pull/81

benfen commented 2 years ago

Had some weird issues with the build not liking a <script> tag. It's back to working again.

benfen commented 2 years ago

@bgschiller It's definitely possible - I added it to source control since I don't expect it to change frequently in comparison to the JS source code and I didn't want to add that as an additional build step/dependency.