Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda