Added test method to modify test object texture
This commit is contained in:
parent
b5792f6fbc
commit
1289d7cf52
|
@ -21,7 +21,7 @@ Studio =
|
|||
checkWebGLsupport: ->
|
||||
return !!window.WebGLRenderingContext;
|
||||
|
||||
# ChangeCamera
|
||||
# Callbacks
|
||||
onCameraChange: (cameraType) ->
|
||||
if "#{cameraType}Camera" of StudioObjects
|
||||
@camera = StudioObjects["#{cameraType}Camera"].init @width, @height
|
||||
|
@ -36,6 +36,7 @@ Studio =
|
|||
requestAnimationFrame =>
|
||||
@animate()
|
||||
|
||||
# Scene helpers
|
||||
setSize: (width, height) ->
|
||||
@width = parseInt width
|
||||
@height = parseInt height
|
||||
|
@ -44,6 +45,18 @@ Studio =
|
|||
@domElement.style.width = "#{@width}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) ->
|
||||
if not @checkWebGLsupport()
|
||||
return false
|
||||
|
@ -58,6 +71,11 @@ Studio =
|
|||
@scene = new THREE.Scene()
|
||||
|
||||
# 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()
|
||||
|
||||
@scene.add @object
|
||||
|
|
|
@ -63,6 +63,11 @@ window.onload = function() {
|
|||
mcstudio.onCameraChange($(this).val())
|
||||
})
|
||||
$("select.camera-type").change()
|
||||
|
||||
$('[data-studio="change-texture"]').click(function() {
|
||||
var texture = $(this).attr('data-texture')
|
||||
mcstudio.changeTexture(texture)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -126,7 +131,9 @@ window.onload = function() {
|
|||
<hr class="margin-none"/>
|
||||
<div class="texture-list">
|
||||
{% 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">
|
||||
<img src="/static/textures/{{ item.get_image(2) }}" />
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue