Added test method to modify test object texture
This commit is contained in:
parent
b5792f6fbc
commit
1289d7cf52
|
@ -21,7 +21,7 @@ Studio =
|
||||||
checkWebGLsupport: ->
|
checkWebGLsupport: ->
|
||||||
return !!window.WebGLRenderingContext;
|
return !!window.WebGLRenderingContext;
|
||||||
|
|
||||||
# ChangeCamera
|
# Callbacks
|
||||||
onCameraChange: (cameraType) ->
|
onCameraChange: (cameraType) ->
|
||||||
if "#{cameraType}Camera" of StudioObjects
|
if "#{cameraType}Camera" of StudioObjects
|
||||||
@camera = StudioObjects["#{cameraType}Camera"].init @width, @height
|
@camera = StudioObjects["#{cameraType}Camera"].init @width, @height
|
||||||
|
@ -36,6 +36,7 @@ Studio =
|
||||||
requestAnimationFrame =>
|
requestAnimationFrame =>
|
||||||
@animate()
|
@animate()
|
||||||
|
|
||||||
|
# Scene helpers
|
||||||
setSize: (width, height) ->
|
setSize: (width, height) ->
|
||||||
@width = parseInt width
|
@width = parseInt width
|
||||||
@height = parseInt height
|
@height = parseInt height
|
||||||
|
@ -44,6 +45,18 @@ Studio =
|
||||||
@domElement.style.width = "#{@width}px"
|
@domElement.style.width = "#{@width}px"
|
||||||
@domElement.style.height = "#{@height}px"
|
@domElement.style.height = "#{@height}px"
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
changeTexture: (path) ->
|
||||||
|
@scene.remove @object
|
||||||
|
|
||||||
|
texture = new THREE.ImageUtils.loadTexture path
|
||||||
|
texture.minFilter = THREE.NearestFilter
|
||||||
|
texture.magFilter = THREE.NearestFilter
|
||||||
|
material = new THREE.MeshLambertMaterial map: texture
|
||||||
|
@object = new THREE.Mesh new THREE.CubeGeometry(16, 16, 16), material
|
||||||
|
@object.rotation.set Math.PI/6, (Math.PI/4)*-1, 0
|
||||||
|
@scene.add @object
|
||||||
|
|
||||||
init: (dom, width, height) ->
|
init: (dom, width, height) ->
|
||||||
if not @checkWebGLsupport()
|
if not @checkWebGLsupport()
|
||||||
return false
|
return false
|
||||||
|
@ -58,6 +71,11 @@ Studio =
|
||||||
@scene = new THREE.Scene()
|
@scene = new THREE.Scene()
|
||||||
|
|
||||||
# test
|
# test
|
||||||
|
@light = new THREE.DirectionalLight 0xffffff
|
||||||
|
@light.position.set(1, 20, 60).normalize()
|
||||||
|
@light.intensity = 1.6
|
||||||
|
@scene.add @light
|
||||||
|
|
||||||
@object = new THREE.Mesh new THREE.CubeGeometry(16, 16, 16), new THREE.MeshNormalMaterial()
|
@object = new THREE.Mesh new THREE.CubeGeometry(16, 16, 16), new THREE.MeshNormalMaterial()
|
||||||
|
|
||||||
@scene.add @object
|
@scene.add @object
|
||||||
|
|
|
@ -63,6 +63,11 @@ window.onload = function() {
|
||||||
mcstudio.onCameraChange($(this).val())
|
mcstudio.onCameraChange($(this).val())
|
||||||
})
|
})
|
||||||
$("select.camera-type").change()
|
$("select.camera-type").change()
|
||||||
|
|
||||||
|
$('[data-studio="change-texture"]').click(function() {
|
||||||
|
var texture = $(this).attr('data-texture')
|
||||||
|
mcstudio.changeTexture(texture)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -126,7 +131,9 @@ window.onload = function() {
|
||||||
<hr class="margin-none"/>
|
<hr class="margin-none"/>
|
||||||
<div class="texture-list">
|
<div class="texture-list">
|
||||||
{% for item in textures %}
|
{% for item in textures %}
|
||||||
<div class="item" data-type="texture" data-name="{{ item.name }}">
|
<div class="item" data-type="texture" data-name="{{ item.name }}"
|
||||||
|
data-texture="/static/textures/{{ item.get_image() }}"
|
||||||
|
data-studio="change-texture">
|
||||||
<div class="codexicon x2">
|
<div class="codexicon x2">
|
||||||
<img src="/static/textures/{{ item.get_image(2) }}" />
|
<img src="/static/textures/{{ item.get_image(2) }}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue