Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
Call function inside module on javascript?

I'm starting a project that uses three.js library, and I will use also a parallax library. The 3D effects will be only decorative, but parallax will trigger it.

I modified this example and works fine for me: demo: https://threejs.org/examples/#webgl_geometry_text_shapes code: https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_text_shapes.html

...but I need to send the title of every section (when the user enter on it by scrolling down) to the 3D script code, and it is closed inside a module.

...How to to it? I'm newbie into three.js and modules, and want to keep the parallax as is (outside module, because it's a well-known library and part of developed yet project)

Maybe the right way is transform the sample code, without modules... but I'm lost with it... for example, the starting part of JS in module, are:

import * as THREE from 'three';

import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { SVGLoader } from './jsm/loaders/SVGLoader.js';
import { FontLoader } from './jsm/loaders/FontLoader.js';

...how to do it without modules / import?

Thanks in advance

==================================

I add an example (maximum simplified) about what I need (and not works):

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>three.js webgl - simple text from json</title>
    </head>
    <body>
        <script type="module">
            init();
            function init() {
                function hi( text) {
                    alert(text);
                }
            } // end init
        </script>
        <script>
            init().hi("hi world");
        </script>
    </body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I solved this turning the code into regular JS, not module JS.

In the library three.js, there is for each control a version for module (into /jsm folder) and normal JS version (/js folder).

Also changed the main file three.module.js for three.js file.

Thank you

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda