Skip to content

Commit

Permalink
Merge pull request #461 from MetaCell/feature/459
Browse files Browse the repository at this point in the history
#459 fix: Update default draco decoder path
  • Loading branch information
enicolasgomez authored Jan 10, 2023
2 parents 57a40f5 + 3e41f8f commit ecce8b3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
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

0 comments on commit ecce8b3

Please sign in to comment.