@awayjs/scene 0.13.312 → 0.13.313

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,9 +6,7 @@ import { IEntity } from '@awayjs/view';
6
6
 
7
7
  import { Style, TriangleElements } from '@awayjs/renderer';
8
8
 
9
- import { MaterialBase } from '@awayjs/materials';
10
-
11
- import { Graphics, Shape, GraphicsFactoryHelper, MaterialManager } from '@awayjs/graphics';
9
+ import { Graphics, Shape, GraphicsFactoryHelper, MaterialManager, SolidFillStyle, TextureAtlas } from '@awayjs/graphics';
12
10
 
13
11
  import { TesselatedFontTable } from '../text/TesselatedFontTable';
14
12
  import { AntiAliasType } from '../text/AntiAliasType';
@@ -617,17 +615,18 @@ export class TextField extends DisplayObjectContainer {
617
615
  }
618
616
 
619
617
  if (this.cursorShape.style.color !== color) {
620
- const alpha = ColorUtils.float32ColorToARGB(color)[0];
621
-
622
- const obj = MaterialManager.getMaterialForColor(color, (alpha / 255) || 1);
623
-
624
- if (obj.colorPos) {
625
- this.cursorShape.style = new Style();
626
- const sampler: ImageSampler = new ImageSampler();
627
- obj.material.animateUVs = true;
628
- this.cursorShape.style.color = color;
629
- this.cursorShape.style.addSamplerAt(sampler, obj.material.getTextureAt(0));
630
- this.cursorShape.style.uvMatrix = new Matrix(0, 0, 0, 0, obj.colorPos.x, obj.colorPos.y);
618
+ const solid = new SolidFillStyle(
619
+ color,
620
+ ColorUtils.float32ColorToARGB(color)[0] / 255 || 1
621
+ );
622
+ const material = MaterialManager.getMaterialForColor(solid);
623
+ const shape = this.cursorShape;
624
+
625
+ shape.material = material;
626
+ if (material.getNumTextures()) {
627
+ shape.style = new Style();
628
+ shape.style.image = TextureAtlas.getTextureForColor(solid);
629
+ shape.style.uvMatrix = solid.getUVMatrix();
631
630
  }
632
631
  }
633
632
  this.scrollToCursor(x,y);
@@ -2747,34 +2746,31 @@ export class TextField extends DisplayObjectContainer {
2747
2746
  textShape.elements.setPositions(attr);
2748
2747
  textShape.elements.invalidate();
2749
2748
 
2750
- textShape.shape = <Shape> this.targetGraphics.addShape(Shape.getShape(textShape.elements));
2749
+ const shape = textShape.shape = <Shape> this.targetGraphics.addShape(Shape.getShape(textShape.elements));
2751
2750
 
2752
2751
  // has BUG for QWOP, temporarily enable it (default)
2753
- textShape.shape.deepHitCheck = true;
2754
- textShape.shape.usages++;
2755
-
2756
- const sampler: ImageSampler = new ImageSampler();
2757
- textShape.shape.style = new Style();
2758
- if (textShape.format.material && this._textColor == 0) {
2759
- textShape.shape.material = this._textFormats[0].material;
2760
- textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
2761
- (<MaterialBase> textShape.shape.material).animateUVs = true;
2762
- textShape.shape.style.uvMatrix =
2752
+ shape.deepHitCheck = true;
2753
+ shape.usages++;
2754
+ shape.style = new Style();
2755
+
2756
+ if (textShape.format.bitmap && this._textColor == 0) {
2757
+ shape.material = MaterialManager.getMaterialForBitmap(true);
2758
+ shape.style.image = this._textFormats[0].bitmap;
2759
+ shape.style.uvMatrix =
2763
2760
  new Matrix(0, 0, 0, 0, textShape.format.uv_values[0], textShape.format.uv_values[1]);
2764
2761
  } else {
2765
2762
 
2766
2763
  const color = this.getTextColorForTextFormat(textShape.format);
2767
- let alpha = ColorUtils.float32ColorToARGB(color)[0];
2768
- if (alpha == 0) {
2769
- alpha = 255;
2770
- }
2771
- const obj = MaterialManager.getMaterialForColor(color, alpha / 255);
2772
-
2773
- textShape.shape.material = obj.material;
2774
- if (obj.colorPos) {
2775
- textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
2776
- (<MaterialBase> textShape.shape.material).animateUVs = true;
2777
- textShape.shape.style.uvMatrix = new Matrix(0, 0, 0, 0, obj.colorPos.x, obj.colorPos.y);
2764
+ const solid = new SolidFillStyle(
2765
+ color,
2766
+ ColorUtils.float32ColorToARGB(color)[0] / 255 || 1
2767
+ );
2768
+
2769
+ const material = MaterialManager.getMaterialForColor(solid);
2770
+ shape.material = material;
2771
+ if (material.getNumTextures()) {
2772
+ shape.style.image = TextureAtlas.getTextureForColor(solid);
2773
+ shape.style.uvMatrix = solid.getUVMatrix();
2778
2774
  }
2779
2775
  }
2780
2776
  }
@@ -2862,9 +2858,6 @@ export class TextField extends DisplayObjectContainer {
2862
2858
  continue;
2863
2859
  }
2864
2860
 
2865
- const color = this.getTextColorForTextFormat(textShape.format);
2866
- const alpha = ColorUtils.float32ColorToARGB(color)[0] || 255;
2867
-
2868
2861
  textShape.elements = new TriangleElements();
2869
2862
 
2870
2863
  textShape.elements.setPositions(attr);
@@ -2875,37 +2868,41 @@ export class TextField extends DisplayObjectContainer {
2875
2868
 
2876
2869
  textShape.elements.invalidate();
2877
2870
 
2878
- textShape.shape = Shape.getShape(textShape.elements);
2871
+ const shape = textShape.shape = Shape.getShape(textShape.elements);
2879
2872
  // has BUG for QWOP, temporarily enable it (default)
2880
- textShape.shape.deepHitCheck = true;
2881
- textShape.shape.usages++;
2873
+ shape.deepHitCheck = true;
2874
+ shape.usages++;
2882
2875
 
2883
- const sampler: ImageSampler = new ImageSampler(false, true, true);
2884
- textShape.shape.style = new Style();
2876
+ shape.style = new Style();
2877
+ shape.style.sampler = new ImageSampler(false, true, true);
2885
2878
 
2886
- if (textShape.fntMaterial) {
2879
+ if (textShape.fntBitmap) {
2887
2880
  // used by FNT fonts
2888
- textShape.shape.material = textShape.fntMaterial;
2889
- textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
2881
+ shape.material = MaterialManager.getMaterialForBitmap();
2882
+ shape.style.image = textShape.fntBitmap;
2890
2883
  //(<MaterialBase> textShape.shape.material).colorTransform=new ColorTransform();
2891
2884
  //(<MaterialBase> textShape.shape.material).colorTransform.color=color;
2892
- } else if (textShape.format.material && this._textColor == 0) {
2885
+ } else if (textShape.format.bitmap && this._textColor == 0) {
2893
2886
  // used for textfields loaded from awd.
2894
2887
  // the material on the format uses textureAtlas from awd
2895
- textShape.shape.material = this._textFormats[0].material;
2896
- textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
2897
- (<MaterialBase> textShape.shape.material).animateUVs = true;
2898
- textShape.shape.style.uvMatrix =
2888
+ shape.material = MaterialManager.getMaterialForBitmap(true);
2889
+ shape.style.image = this._textFormats[0].bitmap;
2890
+ shape.style.uvMatrix =
2899
2891
  new Matrix(0, 0, 0, 0, textShape.format.uv_values[0], textShape.format.uv_values[1]);
2900
2892
  } else {
2901
2893
  // used by runtime textureatlas.
2902
2894
  // (standart for dynamic created text and text loaded from swf)
2903
- const obj = MaterialManager.getMaterialForColor(color, alpha / 255);
2904
- textShape.shape.material = obj.material;
2905
- if (obj.colorPos) {
2906
- textShape.shape.style.addSamplerAt(sampler, textShape.shape.material.getTextureAt(0));
2907
- (<MaterialBase> textShape.shape.material).animateUVs = true;
2908
- textShape.shape.style.uvMatrix = new Matrix(0, 0, 0, 0, obj.colorPos.x, obj.colorPos.y);
2895
+ const color = this.getTextColorForTextFormat(textShape.format);
2896
+ const solid = new SolidFillStyle(
2897
+ color,
2898
+ ColorUtils.float32ColorToARGB(color)[0] / 255 || 1
2899
+ );
2900
+
2901
+ const material = MaterialManager.getMaterialForColor(solid);
2902
+ shape.material = material;
2903
+ if (material.getNumTextures()) {
2904
+ shape.style.image = TextureAtlas.getTextureForColor(solid);
2905
+ shape.style.uvMatrix = solid.getUVMatrix();
2909
2906
  }
2910
2907
  }
2911
2908
  }
@@ -15,7 +15,7 @@ export class TextSprite extends Sprite {
15
15
  const tf: TextField = this.parentTextField;
16
16
  //tf.reConstruct(true);
17
17
 
18
- if (tf._textFormats[0] && !tf._textFormats[0].font_table.isAsset(TesselatedFontTable) && !tf._textFormats[0].material) {
18
+ if (tf._textFormats[0] && !tf._textFormats[0].font_table.isAsset(TesselatedFontTable) && !tf._textFormats[0].bitmap) {
19
19
  this.transform.colorTransform.color = (tf.textColor != null) ? tf.textColor : tf._textFormats[0].color;
20
20
  this._invalidateHierarchicalProperty(HierarchicalProperty.COLOR_TRANSFORM);
21
21
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { ContainerNode, View } from '@awayjs/view';
3
- import { MaterialBase, MethodMaterial } from '@awayjs/materials';
3
+ import { MaterialBase } from '@awayjs/materials';
4
4
  import { DisplayObjectContainer } from '../display/DisplayObjectContainer';
5
5
  import { DisplayObject } from '../display/DisplayObject';
6
6
  import { Billboard } from '../display/Billboard';
@@ -25,7 +25,8 @@ import { Stage,
25
25
  Image2D
26
26
  } from '@awayjs/stage';
27
27
 
28
- import { DefaultRenderer, RenderGroup, Style } from '@awayjs/renderer';
28
+ import { DefaultRenderer, RenderGroup } from '@awayjs/renderer';
29
+ import { MaterialManager } from '@awayjs/graphics';
29
30
 
30
31
  // empty matrix for transform reset
31
32
  const TMP_POINT = new Point(0,0);
@@ -230,12 +231,7 @@ export class SceneImage2D extends BitmapImage2D {
230
231
  SceneImage2D._billboardRenderer.disableClear = true;
231
232
  SceneImage2D._billboardRenderer.renderableSorter = null;//new RenderableSort2D();
232
233
 
233
- const mat: MethodMaterial = new MethodMaterial(new BitmapImage2D(128, 128, true, 0x0));
234
- mat.bothSides = true;
235
- mat.alphaBlending = true;
236
-
237
- SceneImage2D._billboard = new Billboard(mat);
238
- SceneImage2D._billboard.style = new Style();
234
+ SceneImage2D._billboard = new Billboard(MaterialManager.getMaterialForBitmap());
239
235
 
240
236
  SceneImage2D._billboardRoot.addChild(SceneImage2D._billboard);
241
237
  }
@@ -683,13 +679,13 @@ export class SceneImage2D extends BitmapImage2D {
683
679
  const root = SceneImage2D._billboardRoot;
684
680
  const billboard = SceneImage2D._billboard;
685
681
 
686
- billboard.sampler.smooth = smoothing;
682
+ billboard.style.sampler.smooth = smoothing;
687
683
 
688
684
  renderer.disableClear = !useTmp;
689
685
  renderer.view.target = target;
690
686
  renderer.view.projection.scale = 1000 / target.height;
691
687
 
692
- billboard.material.style.image = source;
688
+ billboard.style.image = source;
693
689
 
694
690
  // not all blend modes can be used for rendering
695
691
  billboard.material.blendMode = !useTmp ? mappedBlend : BlendMode.LAYER;
@@ -741,6 +737,8 @@ export class SceneImage2D extends BitmapImage2D {
741
737
  stage.filterManager.pushTemp(target);
742
738
  }
743
739
 
740
+ //reset material blendMode
741
+ billboard.material.blendMode = BlendMode.NORMAL;
744
742
  }
745
743
 
746
744
  private _drawAsDisplay(
@@ -1,12 +1,10 @@
1
- import { Matrix, AssetBase, Point, Rectangle, ColorTransform, ColorUtils } from '@awayjs/core';
1
+ import { AssetBase, Point, Rectangle, ColorTransform, ColorUtils } from '@awayjs/core';
2
2
 
3
- import { ImageSampler, AttributesBuffer, Float2Attributes, AttributesView, BitmapImage2D, Stage } from '@awayjs/stage';
3
+ import { AttributesBuffer, Float2Attributes, AttributesView, BitmapImage2D, Stage } from '@awayjs/stage';
4
4
 
5
5
  import { Style, TriangleElements } from '@awayjs/renderer';
6
6
 
7
- import { GraphicsPath, Shape, GraphicsFactoryFills, GraphicsFactoryHelper, MaterialManager, GraphicsPathCommand } from '@awayjs/graphics';
8
-
9
- import { MaterialBase, MethodMaterial } from '@awayjs/materials';
7
+ import { GraphicsPath, Shape, GraphicsFactoryFills, GraphicsFactoryHelper, MaterialManager, GraphicsPathCommand, SolidFillStyle, TextureAtlas } from '@awayjs/graphics';
10
8
 
11
9
  import { TesselatedFontChar } from './TesselatedFontChar';
12
10
  import { IFontTable } from './IFontTable';
@@ -357,20 +355,17 @@ export class TesselatedFontTable extends AssetBase implements IFontTable {
357
355
  attributesView.dispose();
358
356
  const elements = new TriangleElements(vertexBuffer);
359
357
  elements.setPositions(new Float2Attributes(vertexBuffer));
360
- const shape = Shape.getShape(elements);
361
358
 
362
- const sampler: ImageSampler = new ImageSampler();
363
- shape.style = new Style();
359
+ const shape = Shape.getShape(elements);
360
+ const solid = new SolidFillStyle(0xFFFFFF, 1);
361
+ const material = MaterialManager.getMaterialForColor(solid);
364
362
 
365
- const color = 0xFFFFFF;
366
- const alpha = 1;
367
- const obj = MaterialManager.getMaterialForColor(color, alpha);
363
+ shape.material = material;
368
364
 
369
- shape.material = obj.material;
370
- if (obj.colorPos) {
371
- shape.style.addSamplerAt(sampler, shape.material.getTextureAt(0));
372
- (<MaterialBase> shape.material).animateUVs = true;
373
- shape.style.uvMatrix = new Matrix(0, 0, 0, 0, obj.colorPos.x, obj.colorPos.y);
365
+ if (material.getNumTextures()) {
366
+ shape.style = new Style();
367
+ shape.style.image = TextureAtlas.getTextureForColor(solid);
368
+ shape.style.uvMatrix = solid.getUVMatrix();
374
369
  }
375
370
  shapes[i] = shape;
376
371
  }
@@ -748,17 +743,11 @@ export class TesselatedFontTable extends AssetBase implements IFontTable {
748
743
  private _queryShape (tf: TextField, format: TextFormat, channel = -1): TextShape {
749
744
  const textShape = tf.getTextShapeForIdentifierAndFormat(this._cacheKey(format.color, channel), format);
750
745
 
751
- if (channel >= 0 && !textShape.fntMaterial) {
746
+ if (channel >= 0 && !textShape.fntBitmap) {
752
747
  const argb = ColorUtils.float32ColorToARGB(format.color);
753
- const mat = new MethodMaterial(this._fnt_channels[channel]);
754
-
755
- mat.colorTransform = new ColorTransform(argb[1] / 255, argb[2] / 255, argb[3] / 255);
756
- mat.bothSides = true;
757
- mat.alphaBlending = true;
758
- mat.useColorTransform = true;
759
- mat.style.sampler = new ImageSampler(false, true, true);
760
748
 
761
- textShape.fntMaterial = mat;
749
+ textShape.fntBitmap = this._fnt_channels[channel];
750
+ textShape.fntColorTransform = new ColorTransform(argb[1] / 255, argb[2] / 255, argb[3] / 255);
762
751
  }
763
752
 
764
753
  return textShape;
@@ -1,5 +1,5 @@
1
1
  import { AssetBase } from '@awayjs/core';
2
- import { IMaterial } from '@awayjs/renderer';
2
+ import { Image2D } from '@awayjs/stage';
3
3
  import { IFontTable } from './IFontTable';
4
4
  import { FontStyleName } from './FontStyleName';
5
5
  import { TextFormatAlign } from './TextFormatAlign';
@@ -366,7 +366,7 @@ export class TextFormat extends AssetBase {
366
366
  * The material to use for texturing geometry generated for this text-format.
367
367
  * this material will be used by the TextField
368
368
  */
369
- public material: IMaterial;
369
+ public bitmap: Image2D;
370
370
 
371
371
  /**
372
372
  * The uv-values of the colors in textureatlas.
@@ -2,16 +2,17 @@ import { TriangleElements } from '@awayjs/renderer';
2
2
 
3
3
  import { Shape } from '@awayjs/graphics';
4
4
 
5
- import { MaterialBase } from '@awayjs/materials';
6
-
7
5
  import { TextFormat } from './TextFormat';
6
+ import { BitmapImage2D } from '@awayjs/stage';
7
+ import { ColorTransform } from '@awayjs/core';
8
8
 
9
9
  export class TextShape {
10
10
 
11
11
  public verts: Array<Float32Array> = [];
12
12
  public uvs: Array<Float32Array> = [];
13
13
  public shape: Shape;
14
- public fntMaterial: MaterialBase;
14
+ public fntBitmap: BitmapImage2D;
15
+ public fntColorTransform: ColorTransform;
15
16
  public elements: TriangleElements;
16
17
 
17
18
  private _length: number = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awayjs/scene",
3
- "version": "0.13.312",
3
+ "version": "0.13.313",
4
4
  "description": "AwayJS scene classes",
5
5
  "main": "bundle/awayjs-scene.umd.js",
6
6
  "module": "dist/index.js",