Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBJLoader2 and OBJLoader2Parallel V3.0.0-beta2 #16887

Merged
merged 6 commits into from
Jun 25, 2019

Conversation

kaisalmen
Copy link
Contributor

@kaisalmen kaisalmen commented Jun 22, 2019

This addresses #16688 and it brings back worker based parsing via OBJLoader2Parallel and independent WorkerExecutionSupport.

POIs:

  • OBJLoader2Parallel extends OBJLoader2 and runs the parser inside a worker. Nothing the old version didn't do.
  • It now either uses some of the modules from obj2 to build the worker code or it uses OBJLoader2Worker to directly feed a module into the Worker both via WorkerExecutionSupport. This feature is only experimentally available in Chrome and no other browser as far as I know. It is beautifully simple that's why I put it in already. See for yourself:
import { OBJLoader2Parser } from "../OBJLoader2Parser.js";
import {
	WorkerRunner,
	DefaultWorkerPayloadHandler
} from "../WorkerRunner.js";

new WorkerRunner( new DefaultWorkerPayloadHandler( new OBJLoader2Parser() ) );
  • If no directly loading a jsm module, the new version of WorkerExecutionSupport takes modules loaded into memory and serializes them to a Blob. I wanted to use rollup/babel directly in the browser, but it was always a dead end street. The solution now allows to serialize any module that is available when serialization takes place code (see OBJLoader2Parallel imports imports and OBJLoader2Parallel buildWorkerCode. @donmccurdy this part could be of interest also to you: I want to further modularize WorkerExecutionSupport so you can plug in a standard or own com-protocol on main and worker and are able to use common serialization functions, etc. I will write my ideas down in the Generic Worker Loader issue in the upcoming days.
  • Examples are fine now
  • Code doc seems fine to me, too

Typescript bindings are missing. Can you hint me to a guide/issue how to approach this? Thank you...

@mrdoob mrdoob added this to the r106 milestone Jun 23, 2019
@mrdoob
Copy link
Owner

mrdoob commented Jun 23, 2019

Seems like you included three.js builds in the PR by mistake.

Deleted non jsm code and removed obj2 examples currently not working.
…dules.

WorkerExecutionSupport allows to run runtime code or pre-defined modules (if browser support is available) in a web worker.
@kaisalmen
Copy link
Contributor Author

kaisalmen commented Jun 23, 2019

Sorry for that. I fixed first commit and force pushed the branch.

WorkerExecutionSupport: buildWorker uses CodeBuilderInstructions to decide how to internally build the worker (standard or jsm based)
@kaisalmen
Copy link
Contributor Author

This good to go from my side (see updated description). What about the Typescript definitions?

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 24, 2019

What about the Typescript definitions?

I think it's okay if you add it with a different PR. This one is already big and contains many changes.

@Mugen87 Mugen87 changed the title WIP: OBJLoader2 and OBJLoader2Parallel V3.0.0-beta2 OBJLoader2 and OBJLoader2Parallel V3.0.0-beta2 Jun 24, 2019
@kaisalmen
Copy link
Contributor Author

All LGTM issues are fixed and I updated the description once more. I did it in a rush yesterday.

@mrdoob mrdoob merged commit 4b18dbe into mrdoob:dev Jun 25, 2019
@mrdoob
Copy link
Owner

mrdoob commented Jun 25, 2019

Thanks!

@kaisalmen kaisalmen deleted the OBJLoader2_V300_Beta2 branch June 25, 2019 20:16
@unphased
Copy link
Contributor

unphased commented Jun 26, 2019

Hi, I'm trying out ES6 modules and r106, I successfully got THREE imported as modules in my code like so:

import * as THREE from 'https://threejs.org/build/three.module.js';
import { OBJLoader2 } from 'https://threejs.org/examples/jsm/loaders/OBJLoader2.js';

The problem that I have is that the loadMtl function has completely vanished from OBJLoader2, so I don't know how to make my code work again. I will start to tie the code to r105 for the time being.

Was hoping you guys could point me in a direction. I wonder if I'm trying to use modules too early.

curl -s https://threejs.org/examples/jsm/loaders/OBJLoader2.js | grep -i loadmtl

gives me no output either.

@kaisalmen
Copy link
Contributor Author

kaisalmen commented Jun 27, 2019

Hi @unphased please look at the basic example. The decision to remove mtl related functions was taken by me in the last release already (jsm code). I have introduced MtlObjBridge with R105 to not have OBJLoader2 depend on MTLLoader. The basic example shows how to resolve this problem:
https://github.com/mrdoob/three.js/blob/dev/examples/webgl_loader_obj2.html#L59-L61
https://github.com/mrdoob/three.js/blob/dev/examples/webgl_loader_obj2.html#L122-L137

Maybe, we should add something to the migration guide. @Mugen87 what do you think?

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 27, 2019

Good idea. If you can formulate one or two (short) sentences, I'll put it in the migration guide.

@kaisalmen
Copy link
Contributor Author

kaisalmen commented Jun 27, 2019

What about this? I activated "Allow edits from maintainers", so you can hopefully copy the raw content:


MTL related functions like loadMtl has been removed from OBJLoader2. Please use MTLLoader and MtlObjBridge as shown in basic obj2 example (required imports and load mtl and obj)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants