-
Notifications
You must be signed in to change notification settings - Fork 315
Refactoring Loader #2641
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
base: master
Are you sure you want to change the base?
Refactoring Loader #2641
Conversation
7d9f96a to
56a8cc9
Compare
56a8cc9 to
ae12118
Compare
ae12118 to
26a584d
Compare
|
Would it be possible to bump three.js in a different PR? |
fac11ea to
3c68c40
Compare
done #2663 |
| // Don’t import Three directly if you want to improve tree shaking. | ||
| // eslint-disable-next-line import/extensions | ||
| import { Vector3 } from 'three/src/math/Vector3.js'; | ||
| // eslint-disable-next-line import/extensions | ||
| import { Quaternion } from 'three/src/math/Quaternion.js'; | ||
| // eslint-disable-next-line import/extensions | ||
| import { Box3 } from 'three/src/math/Box3.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really needed to do the import in 3 lignes?
I understand that it's better than to do
import * as THREE from three
but can't we do something like that instead ?
import { Vector3, Quaternion, Box3 } from three/src/math
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it' needed to import from specific files for the tree shacking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thus that what should be done in all the other itowns files then ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, import { Vector3, Quaternion, Box3 } from three shall be sufficient for webpack to do tree-shaking.
* avoid to externalize three for worker
3c68c40 to
090a417
Compare
| const positionBuffer = new THREE.BufferAttribute(attributes.positions, 3); | ||
| geometry.setAttribute('position', positionBuffer); | ||
|
|
||
| const intensityBuffer = new THREE.BufferAttribute(attributes.intensity, 1); | ||
| const intensityBuffer = new THREE.BufferAttribute(attributes.Intensity, 1); | ||
| geometry.setAttribute('intensity', intensityBuffer); | ||
|
|
||
| const returnNumber = new THREE.BufferAttribute(attributes.returnNumber, 1); | ||
| const returnNumber = new THREE.BufferAttribute(attributes.ReturnNumber, 1); | ||
| geometry.setAttribute('returnNumber', returnNumber); | ||
|
|
||
| const numberOfReturns = new THREE.BufferAttribute(attributes.numberOfReturns, 1); | ||
| const numberOfReturns = new THREE.BufferAttribute(attributes.NumberOfReturns, 1); | ||
| geometry.setAttribute('numberOfReturns', numberOfReturns); | ||
|
|
||
| const classBuffer = new THREE.BufferAttribute(attributes.classification, 1); | ||
| const classBuffer = new THREE.BufferAttribute(attributes.Classification, 1); | ||
| geometry.setAttribute('classification', classBuffer); | ||
|
|
||
| const pointSourceID = new THREE.BufferAttribute(attributes.pointSourceID, 1); | ||
| const pointSourceID = new THREE.BufferAttribute(attributes.PointSourceId, 1); | ||
| geometry.setAttribute('pointSourceID', pointSourceID); | ||
|
|
||
| if (attributes.color) { | ||
| const colorBuffer = new THREE.BufferAttribute(attributes.color, 4, true); | ||
| if (attributes.colors) { | ||
| const colorBuffer = new THREE.BufferAttribute(attributes.colors, 4, true); | ||
| geometry.setAttribute('color', colorBuffer); | ||
| } | ||
| const scanAngle = new THREE.BufferAttribute(attributes.scanAngle, 1); | ||
| const scanAngle = new THREE.BufferAttribute(attributes.ScanAngle, 1); | ||
| geometry.setAttribute('scanAngle', scanAngle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really a good idea to rename the attributes with a capital letter (I uinderstand it comes from the name used by copc library (https://github.com/connormanning/copc.js/blob/master/src/las/extractor.ts)
but then maybe we need to use Position instead of positions and Color instead of colors, or maybe better use a map to associate the name inplural with the name with Capital letter (Array LASAttributes in LasLoader.js)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this part to improve maintainability and future evolution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain the expected future gains?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to add other attributes
https://github.com/connormanning/copc.js/blob/master/src/las/extractor.ts#L173
090a417 to
0f7818e
Compare
0f7818e to
7b362c4
Compare
| externals: [ | ||
| ({ context, request }, callback) => { | ||
| if (request === 'three' && !excludesToExternals.find(p => context.includes(p))) { | ||
| return callback(null, 'three'); | ||
| } | ||
| callback(); | ||
| }, | ||
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes... This is pretty hacky but I don't see another way to do it.
This is in my opinion a reason why the ES bundle in webpack is experimental. We should change the bundler one day!
Description
three.jsexternalsfrom the worker to fix imports inthree.jsthree.jsto use the newserializemethodsitowns_lasworker.js