|
72 | 72 | var element = $(el); |
73 | 73 | var options = opts; |
74 | 74 | var isMouseDown = false; |
75 | | - var currentVal = 0; |
| 75 | + var currentVal = opts.value || 0; |
76 | 76 |
|
77 | 77 | element.wrap('<div/>') |
78 | 78 | var container = $(el).parent(); |
|
134 | 134 | newPos = Math.max(0,newPos); |
135 | 135 | newPos = Math.min(newPos,upperBound); |
136 | 136 | currentVal = Math.round((newPos/upperBound)*100,0); |
| 137 | + if (typeof options.onInput == 'function') { options.onInput(currentVal)} |
137 | 138 |
|
138 | 139 | container.find('.pp-slider-button').css("left", newPos); |
139 | 140 | container.find('.pp-slider-tooltip').html(currentVal+'%'); |
|
150 | 151 | var dropCallback = function (e) { |
151 | 152 | isMouseDown = false; |
152 | 153 | element.val(currentVal); |
153 | | - if(typeof element.options != 'undefined' && typeof element.options.onChanged == 'function'){ |
154 | | - element.options.onChanged.call(this, null); |
| 154 | + if(typeof options.onChanged == 'function'){ |
| 155 | + options.onChanged.call(this, null); |
155 | 156 | } |
156 | 157 |
|
157 | 158 | }; |
|
160 | 161 |
|
161 | 162 | $(document).mousemove(function(e) { moving(e); }); |
162 | 163 | $(document).mouseup(function(e){ dropCallback(e); }); |
| 164 | + |
| 165 | + container.find('.pp-slider-button').css("left", currentVal); |
163 | 166 |
|
164 | 167 | }; |
165 | 168 |
|
|
174 | 177 | } |
175 | 178 |
|
176 | 179 | $.fn.PPSlider.defaults = { |
177 | | - width: 150 |
| 180 | + width: 100 |
178 | 181 | }; |
179 | 182 |
|
180 | 183 |
|
|
338 | 341 | ta = create_textarea() |
339 | 342 | con.appendChild( ta ) |
340 | 343 |
|
341 | | - slider = document.createElement('input') |
342 | | - slider.setAttribute('type', 'hidden') |
343 | | - slider.setAttribute('value', '40') |
344 | | - slider.setAttribute('id', 'myslider') |
345 | | - con.appendChild( slider ) |
346 | | - $("#myslider").PPSlider( width=300 ) |
347 | | - |
348 | | - |
349 | | - #video = this.element3D.create_video( |
350 | | - # mp4='/home/brett/three.js/examples/textures/sintel.mp4', |
351 | | - # ogv='/home/brett/three.js/examples/textures/sintel.ogv' |
352 | | - #) |
353 | | - #this.parentNode.appendChild(video) |
354 | | - |
355 | 344 | pointlight.position.copy( this.element3D.object.position ) |
356 | 345 | pointlight.position.z += 40 |
357 | 346 | gizmo.attach( this.element3D.right_bar ) |
|
438 | 427 | #loader.load( 'http://localhost:8000'+file.path, on_load ) |
439 | 428 |
|
440 | 429 | def onload(evt): |
441 | | - print(evt.target.result) |
| 430 | + global slider |
442 | 431 | parser = new DOMParser() |
443 | 432 | collada = loader.parse( parser.parseFromString(evt.target.result, "application/xml") ) |
444 | 433 | print(collada.scene) |
|
447 | 436 | element3D.root.add( collada.scene ) |
448 | 437 | element3D.collada = collada.scene |
449 | 438 |
|
| 439 | + global X |
| 440 | + X = collada.scene |
| 441 | + for model in collada.scene.children: |
| 442 | + print(model) |
| 443 | + div = document.createElement('div') |
| 444 | + div.setAttribute('class', 'well') |
| 445 | + container.appendChild( div ) |
| 446 | + h3 = document.createElement('h3') |
| 447 | + h3.appendChild( document.createTextNode(model.name) ) |
| 448 | + div.appendChild( h3 ) |
| 449 | + |
| 450 | + if hasattr(model, 'material'): ## could be THREE.Mesh or THREE.SkinnedMesh |
| 451 | + print(model.material) |
| 452 | + slider = document.createElement('input') |
| 453 | + ## the native slider looks different on each platform, |
| 454 | + ## and it is not clickable, because the camera controls preventDefault? |
| 455 | + ## however, if focused the keyboard arrow keys, can still change the slider values. |
| 456 | + ## to be safe, instead of using a native slider, we use the custom jquery/css slider. |
| 457 | + ##slider.setAttribute('type', 'range') ## do not use native slider |
| 458 | + #slider.setAttribute('min', 0) |
| 459 | + #slider.setAttribute('max', 100) |
| 460 | + #slider.setAttribute('step', 1) |
| 461 | + #slider.setAttribute('value', 100) |
| 462 | + |
| 463 | + slider.setAttribute('type', 'hidden') |
| 464 | + sid = 'slider-'+model.name |
| 465 | + slider.setAttribute('id', sid) |
| 466 | + div.appendChild( slider ) |
| 467 | + |
| 468 | + def onchange(val): |
| 469 | + model.material.opacity = val * 0.01 |
| 470 | + #slider.oninput = onchange |
| 471 | + #slider.onchange = onchange |
| 472 | + |
| 473 | + $("#"+sid).PPSlider( width=300, onInput=onchange, value=100 ) |
| 474 | + |
| 475 | + def onclick(e): |
| 476 | + print('slider clicked') |
| 477 | + slider.focus() |
| 478 | + slider.onclick = onclick |
| 479 | + |
| 480 | + |
| 481 | + |
450 | 482 | reader = new FileReader() |
451 | 483 | reader.onload = onload |
452 | 484 | reader.readAsText( file ) |
|
0 commit comments