@@ -2,13 +2,11 @@ import { root } from '../utils/root.js';
22import { Events } from '../events.js' ;
33import { Element } from '../element.js' ;
44import { TwoError } from '../utils/error.js' ;
5- import { CanvasShim } from '../utils/canvas-shim .js' ;
5+ import { CanvasPolyfill } from '../utils/canvas-polyfill .js' ;
66
77import { Vector } from '../vector.js' ;
88import { Registry } from '../registry.js' ;
99
10- import { Renderer as CanvasRenderer } from '../renderers/canvas.js' ;
11-
1210let anchor ;
1311const regex = {
1412 video : / \. ( m p 4 | w e b m | o g g ) $ / i,
@@ -280,10 +278,10 @@ export class Texture extends Element {
280278
281279 let image ;
282280
283- if ( CanvasShim . Image ) {
281+ if ( CanvasPolyfill . Image ) {
284282 // TODO: Fix for headless environments
285- image = new CanvasShim . Image ( ) ;
286- CanvasRenderer . Utils . shim ( image , 'img' ) ;
283+ image = new CanvasPolyfill . Image ( ) ;
284+ CanvasPolyfill . shim ( image , 'img' ) ;
287285 } else if ( root . document ) {
288286 if ( regex . video . test ( absoluteSrc ) ) {
289287 image = document . createElement ( 'video' ) ;
@@ -318,7 +316,7 @@ export class Texture extends Element {
318316
319317 const loaded = function ( e ) {
320318 if (
321- ! CanvasShim . isHeadless &&
319+ ! CanvasPolyfill . isHeadless &&
322320 image . removeEventListener &&
323321 typeof image . removeEventListener === 'function'
324322 ) {
@@ -331,7 +329,7 @@ export class Texture extends Element {
331329 } ;
332330 const error = function ( e ) {
333331 if (
334- ! CanvasShim . isHeadless &&
332+ ! CanvasPolyfill . isHeadless &&
335333 typeof image . removeEventListener === 'function'
336334 ) {
337335 image . removeEventListener ( 'load' , loaded , false ) ;
@@ -348,7 +346,7 @@ export class Texture extends Element {
348346 ) {
349347 loaded ( ) ;
350348 } else if (
351- ! CanvasShim . isHeadless &&
349+ ! CanvasPolyfill . isHeadless &&
352350 typeof image . addEventListener === 'function'
353351 ) {
354352 image . addEventListener ( 'load' , loaded , false ) ;
@@ -357,24 +355,28 @@ export class Texture extends Element {
357355
358356 texture . _src = Texture . getAbsoluteURL ( texture . _src ) ;
359357
360- if ( ! CanvasShim . isHeadless && image && image . getAttribute ( 'two-src' ) ) {
358+ if (
359+ ! CanvasPolyfill . isHeadless &&
360+ image &&
361+ image . getAttribute ( 'two-src' )
362+ ) {
361363 return ;
362364 }
363365
364- if ( ! CanvasShim . isHeadless ) {
366+ if ( ! CanvasPolyfill . isHeadless ) {
365367 image . setAttribute ( 'two-src' , texture . src ) ;
366368 }
367369
368370 Texture . ImageRegistry . add ( texture . src , image ) ;
369371
370- if ( CanvasShim . isHeadless ) {
372+ if ( CanvasPolyfill . isHeadless ) {
371373 Texture . loadHeadlessBuffer ( texture , loaded ) ;
372374 } else {
373375 texture . image . src = texture . src ;
374376 }
375377 } ,
376378 video : function ( texture , callback ) {
377- if ( CanvasShim . isHeadless ) {
379+ if ( CanvasPolyfill . isHeadless ) {
378380 throw new TwoError (
379381 'video textures are not implemented in headless environments.'
380382 ) ;
@@ -428,7 +430,7 @@ export class Texture extends Element {
428430 Texture . Register . canvas ( texture , callback ) ;
429431 } else {
430432 texture . _src =
431- ( ! CanvasShim . isHeadless && image . getAttribute ( 'two-src' ) ) ||
433+ ( ! CanvasPolyfill . isHeadless && image . getAttribute ( 'two-src' ) ) ||
432434 image . src ;
433435 Texture . Register [ tag ] ( texture , callback ) ;
434436 }
0 commit comments