小编Ecb*_*urt的帖子

如何让多个对象播放同一个动画 THREE.js

我正在将一群鸟添加到场景中,但只有其中一只正在播放我加载的动画我在文档中读到您可以使用 THREE.AnimationObjectGroup 但我无法让它工作。我在此循环中加载对象和动画。


for (var numberOfBirds = 0; numberOfBirds < 20; numberOfBirds++) {
    loader.load("./assets/bird.gltf", function (gltf) {

        //Loading in and positioning model
        var bird = gltf.scene;
        bird.scale.set(10, 10, 10);

        bird.position.set(Math.random() * 500, Math.random() * 500, Math.random() * 500);
        var flock = new THREE.AnimationObjectGroup;
        flock.add(bird);
        console.log(flock);

        //Playing Animation
        mixer = new THREE.AnimationMixer(flock);
        console.log(gltf.animations);
        mixer.clipAction(gltf.animations[0]).play();

        scene.add(bird);


    });

}
Run Code Online (Sandbox Code Playgroud)

javascript three.js

1
推荐指数
1
解决办法
1618
查看次数

编译实现和头文件时出错

我正在尝试添加成员函数的定义,game.h但出现编译器错误,指出 void 函数是先前定义的。game.h和 也输出相同的错误game.cpp。这几乎就像pragma once不起作用?我在 Rider 中遇到错误,也在game.cpp文件中说了同样的事情,但仅限于 void 函数。

\n

游戏.h

\n
#pragma once\n\n#include "SDL2/SDL.h"\n\n\nclass Game{\npublic:\n\n    Game() {}\n    ~Game() {}\n\n    bool init(const char* title, int xPos, int yPos, int width,int height, int flags);\n\n\n\n    void render(){};\n    void update(){};\n    void handleEvents(){};\n    void clean(){};\n\n\n    bool running() {return m_bRunning;}\n\nprivate:\n\n    SDL_Window* m_pWindow;\n    SDL_Renderer* m_pRenderer;\n\n    bool m_bRunning{};\n};\n
Run Code Online (Sandbox Code Playgroud)\n

游戏.cpp

\n
#include <iostream>\n#include "game.h"\n\n\nbool Game::init(const char* title, int xPos, int yPos, int width, int height, int flags){\n\n …
Run Code Online (Sandbox Code Playgroud)

c++ sdl cmake header-files

-2
推荐指数
1
解决办法
304
查看次数

标签 统计

c++ ×1

cmake ×1

header-files ×1

javascript ×1

sdl ×1

three.js ×1