Git Product home page Git Product logo

Comments (4)

jnsmalm avatar jnsmalm commented on August 21, 2024

Hello,

Can you doublecheck that the transform is actually there? The transform object is only there if you are setting a texture from a spritesheet or the model you are loading is using texture transform.

console.log(mesh.material.baseColorTexture.transform)

// Add transform if it's not there
mesh.material.baseColorTexture.transform = new TextureTransform()

from pixi3d.

valtver avatar valtver commented on August 21, 2024

Hey,

Thanks, when I create transform during material setup it works.
Just in case, I'm attaching modified "standard material" example code with working scale manipulation. So I guess that transform is there.

import { Application } from "pixi.js";
import {
  Model,
  LightingEnvironment,
  ImageBasedLighting,
  CameraOrbitControl,
  Color,
  StandardMaterialTexture,
  TextureTransform
} from "pixi3d";

import "./styles.css";

let app = new Application({
  backgroundColor: 0xdddddd,
  resizeTo: window,
  antialias: true
});
document.body.appendChild(app.view);

app.loader.add(
  "diffuse.cubemap",
  "https://raw.githubusercontent.com/jnsmalm/pixi3d-examples/master/assets/chromatic/diffuse.cubemap"
);
app.loader.add(
  "specular.cubemap",
  "https://raw.githubusercontent.com/jnsmalm/pixi3d-examples/master/assets/chromatic/specular.cubemap"
);
app.loader.add(
  "teapot.gltf",
  "https://raw.githubusercontent.com/jnsmalm/pixi3d-examples/master/assets/teapot/teapot.gltf"
);
const walltexture = StandardMaterialTexture.from(
  "https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Surfaces_bumpy_walkway_between_sidewalk_and_street_closeup_view.JPG/1280px-Surfaces_bumpy_walkway_between_sidewalk_and_street_closeup_view.JPG"
);
walltexture.transform = new TextureTransform();
walltexture.transform.offset += Math.random()*100;
// const walltexture = StandardMaterialTexture.from(
//   "https://static.wikia.nocookie.net/portalworldsgame/images/a/a7/Background_Block_Icon.png"
// );

var model = new Model();

app.loader.load((_, resources) => {
  // Create and add the model, it uses the standard material by default.
  model = Model.from(resources["teapot.gltf"].gltf);
  app.stage.addChild(model);
  model.y = -0.8;
  model.meshes.forEach((mesh) => {
    mesh.material.unlit = false; // Set unlit = true to disable all lighting.
    // mesh.material.baseColor = new Color(1, 1, 1, 1); // The base color will be blended together with base color texture (if available).
    mesh.material.baseColorTexture = walltexture;
    console.log(mesh.material.baseColorTexture);
    mesh.material.alphaMode = "opaque"; // Set alpha mode to "blend" for transparency (base color alpha less than 1).
    mesh.material.exposure = 2; // Set exposure to be able to control the brightness.
    mesh.material.metallic = 0; // Set to 1 for a metallic material.
    // mesh.material.roughness = 0.3; // Value between 0 and 1 which describes the roughness of the material.
  });

  // Create the image-based lighting (IBL) object which is used to light the model. Depending on which IBL environment is used, it will greatly affect the visual appearence of the model.
  let ibl = new ImageBasedLighting(
    resources["diffuse.cubemap"].cubemap,
    resources["specular.cubemap"].cubemap
  );

  LightingEnvironment.main = new LightingEnvironment(app.renderer, ibl);
});

let control = new CameraOrbitControl(app.view);
control.angles.x = 25;

var t = 0;

app.ticker.add(() => {
  model.meshes.forEach((mesh) => {
    t++;
    
    mesh.material.baseColorTexture.transform.scale.set( Math.sin(t/100), Math.sin(t/100) ); 
  })
});

from pixi3d.

jnsmalm avatar jnsmalm commented on August 21, 2024

If you just load a regular jpg image it won't include a transform by default. Your code must have done something different before, because if I run your code using "transform.scale.set" it's doesn't work if I don't create the texture transform. This is working as intended :-)

from pixi3d.

valtver avatar valtver commented on August 21, 2024

Okay, looks like

mesh.material.baseColorTexture.transform = new TextureTransform()

works as expected so I close that :)

Thanks again

from pixi3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.