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

#459 fix: Update default draco decoder path #461

Merged
merged 3 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class SimpleInstancesExample extends Component {
onSelection={this.onSelection}
onMount={this.onMount}
onHoverListeners={{ 'hoverId':this.hoverHandler }}
dracoDecoderPath={'https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/jsm/libs/draco/'}
/>
</>
</div>
Expand Down
9 changes: 8 additions & 1 deletion geppetto.js/geppetto-ui/src/3d-canvas/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Canvas extends Component {
onMount,
onUpdateStart,
onUpdateEnd,
dracoDecoderPath
} = this.props;
const hasCaptureOptions = captureOptions !== undefined

Expand All @@ -70,7 +71,8 @@ class Canvas extends Component {
selectionStrategy,
onHoverListeners,
onEmptyHoverListener,
hasCaptureOptions
hasCaptureOptions,
dracoDecoderPath
);
onUpdateStart();
await this.threeDEngine.updateInstances(data);
Expand Down Expand Up @@ -429,6 +431,7 @@ Canvas.defaultProps = {
onMount: () => {},
onUpdateStart: () => {},
onUpdateEnd: () => {},
dracoDecoderPath: 'https://www.gstatic.com/draco/versioned/decoders/1.5.5/'
};

Canvas.propTypes = {
Expand Down Expand Up @@ -664,6 +667,10 @@ Canvas.propTypes = {
* Function to callback when the loading of elements of the canvas ends
*/
onUpdateEnd: PropTypes.func,
/**
* Path to the draco decoder
*/
dracoDecoderPath: PropTypes.string
};

export default withStyles(styles)(Canvas);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import particle from '../textures/particle.png';
import { hasVisualType, hasVisualValue } from "./util";
import { hasVisualValue } from "./util";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
import { OBJLoader } from "./OBJLoader";
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
Expand All @@ -16,6 +16,7 @@ export default class MeshFactory {
linePrecisionMinRadius = 300,
minAllowedLinePrecision = 1,
particleTexture,
dracoDecoderPath,
THREE
) {
this.scene = scene;
Expand All @@ -30,6 +31,7 @@ export default class MeshFactory {
this.minAllowedLinePrecision = minAllowedLinePrecision;
this.linesThreshold = linesThreshold;
this.particleTexture = particleTexture;
this.dracoDecoderPath = dracoDecoderPath ? dracoDecoderPath : 'https://www.gstatic.com/draco/versioned/decoders/1.5.5/'
this.THREE = THREE ? THREE : require('three');
this.THREE.Cache.enabled = true;
this.setupLoaders();
Expand All @@ -38,7 +40,7 @@ export default class MeshFactory {

setupLoaders (){
const dracoLoader = new DRACOLoader()
dracoLoader.setDecoderPath('https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/jsm/libs/draco/');
dracoLoader.setDecoderPath(this.dracoDecoderPath);

const manager = new this.THREE.LoadingManager();
manager.onProgress = function (item, loaded, total) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default class ThreeDEngine {
selectionStrategy,
onHoverListeners,
onEmptyHoverListener,
preserveDrawingBuffer
preserveDrawingBuffer,
dracoDecoderPath
) {
this.scene = new THREE.Scene();
this.scene.background = new THREE.Color(backgroundColor);
Expand All @@ -45,7 +46,8 @@ export default class ThreeDEngine {
this.mouse = { x: 0, y: 0 };
this.mouseContainer = { x: 0, y: 0 }
this.frameId = null;
this.meshFactory = new MeshFactory(this.scene, linesThreshold, cameraOptions.depthWrite);
this.meshFactory = new MeshFactory(this.scene, linesThreshold, cameraOptions.depthWrite, 300, 1,
null, dracoDecoderPath, null);
this.pickingEnabled = pickingEnabled;
this.onHoverListeners = onHoverListeners;
this.onEmptyHoverListener = onEmptyHoverListener ;
Expand Down