PIXI.js Is there a way to have a mask only affect shape and not colour? - pixi.js

const filter = new PIXI.SpriteMaskFilter(mask)
sprite.filters = [filter]
Similar problems:
https://www.html5gamedevs.com/topic/35812-is-there-a-way-to-have-a-mask-only-affect-shape-and-not-colour/
https://www.html5gamedevs.com/topic/33919-clipping-one-sprite-with-other-using-pixijs-mask-while-keeping-masked-one-original-colors/
No solution was found after checking the document

Related

extendscript after effects colorize not working or how do i add it

am trying to add the effect Colorize Blue wash or Colorize -blue wash to my seleced layer it does not work.
when manually selected it adds color balance and color balance hld with modified setting .
now how do i use my code
var myComp = app.project.activeItem;
var preCompLayer = myComp.selectedLayers[0];
preCompLayer.property("Effects").addProperty("Colorize - blue wash");
image below snapshot
You are attempting to apply a preset as though are you applying an effect. First you'll need to find the path to the preset file in your After Effects installation. You can apply the preset like so:
var myComp = app.project.activeItem;
var preCompLayer = myComp.selectedLayers[0];
// Path to your preset file below
var presetFile = File("/your-After-Effects-path/Presets/Image - Creative/Colorize - blue wash.ffx");
preCompLayer.applyPreset(presetFile);

How to change the size and shape of a CollisionShape (3D) in runtime?

I'm trying to make my game more dynamic by making attack hitboxes scaleable. However when adding a new shape to the current CollisionShape it shows the correct radius when printing but the radius ingame is not corresponding to the new value.
The code I currently use is this:
var shape = CylinderShape.new()
shape.set_radius(new_radius)
shape.set_height(new_height)
$Spatial/CollisionShape.shape = shape
When running this I tried to print the current CollisionShape.shape.radius and it showed the new number however ingame the collisionshape is still the old shape and nothing changed (both visually with the debug option on and when testing the collision size)
So my question is: how do I change the shape or size of the shape in runtime.
Things I've already tried:
$Spatial/CollisionShape.shape.radius = new_radius
$Spatial/CollisionShape.shape.height = new_height
This gave the same result unfortunately. I've also tried to make the shape null before putting the new shape in the CollisionShape. This changed nothing aswell.
Am I missing something?
It looks like it's not possible to update a collisioon shape; you have to create a new one. I solved it like this, where I have a CSGBox which owns a StaticBody which owns a CollisionShape, and I want to make the static body's collision shape match the CSGBox:
var box : BoxShape = BoxShape.new()
box.extents.x = self.width/2
box.extents.y = self.height/2
box.extents.z = self.depth/2
$StaticBody/CollisionShape.shape = box
(This script is attached to the CSGBox).

Easily convert between Fabric JS IText and Textbox?

Is there a way to easily convert a Fabric JS IText into a TextBox (new in 1.6.0) and vice versa, without having to laboriously read and set every single property of them, i.e. some quick way of mapping between them?
Thanks.
you can easily do
var text = oldItext.text;
var textobj = oldItext.toObject();
delete textobj.text;
delete textobj.type;
var clonedtextobj = JSON.parse(JSON.stringify(textobj));
var textbox = new fabric.Textbox(text, clonedtextobj);
a note about use of json:
normal toObject method in Fabricjs does not take care of deep cloning. so the new textbox you create would share the same style object with the old itext. That is not necessarly bad untill you create 2 copies from 1.
if you are not using styles, a faster way is:
var text = oldItext.text;
var textobj = oldItext.toObject();
delete textobj.type;
var textbox = new fabric.Textbox(text, textobj);

(THREE.js) Material isn't working on my custom THREE.Geometry shape

I created a triangle and I am trying to make it red. However it remains black. The problem doesn't seem to be the material as it works on other Geometries I've made.
Here is my triangle:
var triangle = new THREE.Geometry();
triangle.vertices.push(
new THREE.Vector3(-10,10,0),
new THREE.Vector3(-10,-10,0),
new THREE.Vector3(10,-10,0)
);
triangle.faces.push(new THREE.Face3(0,1,2));
triangle.computeBoundingSphere();
this.redtriangle = new THREE.Mesh(triangle, this.redMat)
I tried some suggestions online to color it using:
triangle.faces.push(new THREE.Face3(0,1,2));
triangle.faces[0].vertexColors[0] = new THREE.Color(0xFF0000);
triangle.faces[0].vertexColors[1] = new THREE.Color(0xFF0000);
triangle.faces[0].vertexColors[2] = new THREE.Color(0xFF0000);
My material
this.redMat = new THREE.MeshLambertMaterial ({
color: 0xFF0000,
shading:THREE.FlatShading,
// I added this line for the suggestion above
// vertexColors:THREE.VertexColors,
side:THREE.DoubleSide
})
I've also tried to insert
triangle.colorsNeedUpdate = true;
or
geometry.colorsNeedsUpdate = true;
but no matter what variations/where I put it, it doesn't want to work. The triangle stays black.
Your vertices definition is in clockwise order when it should have been counter-clockwise. So if you change your new THREE.Face3(0,1,2) to new THREE.Face3(0,2,1) you should see something.

o3d textures and transparency

I'm working at galery on o3d(plagin version) and I need make photos transparent. Photos are on hud. Here is some code:
g_canvasInfoPict = o3djs.canvas.create(g_pack, g_hudRoot, g_hudViewInfo);
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.AlphaReference");
alphaParam.value = 0.5;
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.BlendAlphaEquation");
alphaParam.value = g_o3d.State.BLEND_SUBTRACT;
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.SourceBlendFunction");
alphaParam.value = g_o3d.State.BLENDFUNC_ONE;
paramOne = g_canvasInfoPict.transparentState_.getStateParam("o3d.DestinationBlendFunction");
paramOne.value = g_o3d.State.BLENDFUNC_DESTINATION_ALPHA;//or BLENDFUNC_SOURCE_ALPHA or BLENDFUNC_SOURCE_ALPHA_SATUTRATE or BLENDFUNC_ONE or BLENDFUNC_ZERO
g_fullPictCanvas = g_canvasInfoPict.createXYQuad(paddingX, paddingY, -14, g_fullPictTexture.width, g_fullPictTexture.height, true);
g_fullPictCanvas.canvas.drawBitmap(g_fullPictTexture, 0, g_fullPictTexture.height);
g_fullPictCanvas.updateTexture();
But it doesn't work. When setting paramOne.value = BLENDFUNC_ZERO photo displays (non-transparent)
paramOne.value = BLENDFUNC_ONE photo isn't displayed (full transparent)
So how to achive intermediate result?
Given that the O3D plug-in is deprecated in favor of the WebGL-based O3D, is it an option for you to migrate to the latter?
If so, you can inquire in the discussion group about the transparency issue (if it still exists under O3D-WebGL). The developers are very responsive.

Resources