Skip to content

Commit 3241458

Browse files
committed
Editor: Moved THREE.HTML code out of html2canvas.js
1 parent 3d66d1e commit 3241458

File tree

3 files changed

+76
-74
lines changed

3 files changed

+76
-74
lines changed

editor/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
<!-- <script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="qyqgfqd9j8z890t"></script> -->
155155

156156
<script src="js/libs/html2canvas.js"></script>
157+
<script src="js/libs/three.html.js"></script>
157158

158159
<script>
159160

editor/js/libs/html2canvas.js

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -187,77 +187,3 @@ function html2canvas( element ) {
187187
return canvas;
188188

189189
}
190-
191-
//
192-
193-
THREE.HTMLGroup = function ( dom ) {
194-
195-
THREE.Group.call( this );
196-
197-
this.type = 'HTMLGroup';
198-
199-
/*
200-
dom.addEventListener( 'mousemove', function ( event ) {
201-
202-
console.log( 'mousemove' );
203-
204-
} );
205-
206-
dom.addEventListener( 'click', function ( event ) {
207-
208-
console.log( 'click' );
209-
210-
} );
211-
*/
212-
213-
};
214-
215-
THREE.HTMLGroup.prototype = Object.assign( Object.create( THREE.Group.prototype ), {
216-
217-
constructor: THREE.HTMLGroup
218-
219-
} );
220-
221-
THREE.HTMLMesh = function ( dom ) {
222-
223-
var texture = new THREE.HTMLTexture( dom );
224-
225-
var geometry = new THREE.PlaneGeometry( texture.image.width * 0.05, texture.image.height * 0.05 );
226-
var material = new THREE.MeshBasicMaterial( { map: texture } );
227-
228-
THREE.Mesh.call( this, geometry, material );
229-
230-
this.type = 'HTMLMesh';
231-
232-
};
233-
234-
THREE.HTMLMesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), {
235-
236-
constructor: THREE.HTMLMesh
237-
238-
} );
239-
240-
THREE.HTMLTexture = function ( dom ) {
241-
242-
THREE.CanvasTexture.call( this, html2canvas( dom ) );
243-
244-
this.dom = dom;
245-
246-
this.anisotropy = 16;
247-
248-
};
249-
250-
THREE.HTMLTexture.prototype = Object.assign( Object.create( THREE.CanvasTexture.prototype ), {
251-
252-
constructor: THREE.HTMLTexture,
253-
254-
update: function () {
255-
256-
console.log( 'yo!', this, this.dom );
257-
258-
this.image = html2canvas( this.dom );
259-
this.needsUpdate = true;
260-
261-
}
262-
263-
} );

editor/js/libs/three.html.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* @author mrdoob / http://mrdoob.com/
3+
*/
4+
5+
THREE.HTMLGroup = function ( dom ) {
6+
7+
THREE.Group.call( this );
8+
9+
this.type = 'HTMLGroup';
10+
11+
/*
12+
dom.addEventListener( 'mousemove', function ( event ) {
13+
14+
console.log( 'mousemove' );
15+
16+
} );
17+
18+
dom.addEventListener( 'click', function ( event ) {
19+
20+
console.log( 'click' );
21+
22+
} );
23+
*/
24+
25+
};
26+
27+
THREE.HTMLGroup.prototype = Object.assign( Object.create( THREE.Group.prototype ), {
28+
29+
constructor: THREE.HTMLGroup
30+
31+
} );
32+
33+
THREE.HTMLMesh = function ( dom ) {
34+
35+
var texture = new THREE.HTMLTexture( dom );
36+
37+
var geometry = new THREE.PlaneGeometry( texture.image.width * 0.05, texture.image.height * 0.05 );
38+
var material = new THREE.MeshBasicMaterial( { map: texture } );
39+
40+
THREE.Mesh.call( this, geometry, material );
41+
42+
this.type = 'HTMLMesh';
43+
44+
};
45+
46+
THREE.HTMLMesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), {
47+
48+
constructor: THREE.HTMLMesh
49+
50+
} );
51+
52+
THREE.HTMLTexture = function ( dom ) {
53+
54+
THREE.CanvasTexture.call( this, html2canvas( dom ) );
55+
56+
this.dom = dom;
57+
58+
this.anisotropy = 16;
59+
60+
};
61+
62+
THREE.HTMLTexture.prototype = Object.assign( Object.create( THREE.CanvasTexture.prototype ), {
63+
64+
constructor: THREE.HTMLTexture,
65+
66+
update: function () {
67+
68+
console.log( 'yo!', this, this.dom );
69+
70+
this.image = html2canvas( this.dom );
71+
this.needsUpdate = true;
72+
73+
}
74+
75+
} );

0 commit comments

Comments
 (0)