encima / encima/jsc3d

Unable to reset scenes. Old STL data is retained.

Open
#44 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
HTML
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```
What steps will reproduce the problem?
1. I have code which uses the FileReader object and StlLoader.parseStl to
preview files locally. The application is intended to only preview one STL file
at a time. When the first file is loaded I call functions init_viewer() and
init_scene() and then load the file. If the user previews additional files,
init_viewer and init_scene are called, however the geometry of the old files is
visible as a flicker when the user does a mouse move.

What is the expected output? What do you see instead?
-Expected should be normal rendered view of the most recently loaded STL file.
Instead, when there is a mouse-move all previously loaded geometry is visible
as a flicker.

What version of the product are you using? On what operating system?
1.4.2, on ubuntu.

Please provide any additional information below.

Relevant code:

var handle_file_select = function(e) {
e.stopPropagation()
e.preventDefault()
var viewer
var theScene
var f = e.target.files[0]
var reader = new FileReader()
var ext = f.name.split(".")[1]
var mycanvas = document.getElementById('upload_canvas');
var stl_loader = new JSC3D.StlLoader()

function init_viewer() {
viewer = new JSC3D.Viewer(mycanvas);
viewer.setParameter('InitRotationX', 20);
viewer.setParameter('InitRotationY', 20);
viewer.setParameter('InitRotationZ', 0);
viewer.setParameter('ModelColor', '#CAA618');
viewer.setParameter('BackgroundColor1', '#FFFFFF');
viewer.setParameter('BackgroundColor2', '#383840');
viewer.setParameter('RenderMode', "flat");
}

function init_scene() {
theScene = new JSC3D.Scene
if (!(theScene.isEmpty)) {
console.log(theScene)
}
}

reader.onload = (function(file) {
return function(e) {
console.log("old scene: ", theScene)
init_viewer()
init_scene()
stl_loader.parseStl(theScene, e.target.result)
viewer.init()
viewer.replaceScene(theScene)
viewer.update()
}
})(f)

if (ext.toLowerCase() != "stl") {
alert("That doesn't appear to be an STL file.");
} else {
reader.readAsBinaryString(f)
}
}

Sorry to post twice today!

```

Original issue reported on code.google.com by `liav.ko...@gmail.com` on 2 Oct 2013 at 12:42

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the FileReader callback and the init_viewer(), init_scene(), StlLoader.parseStl(), Viewer.init(), replaceScene(), and update() calls shown in the report. Reproduce loading multiple STL files in version 1.4.2 on Ubuntu, then trace how scenes and geometry are retained between previews. Done means only the newest STL geometry is rendered without flicker.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.